Class: Rpub::Preview
- Inherits:
-
Object
- Object
- Rpub::Preview
- Defined in:
- lib/rpub/preview.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(context, source) ⇒ Preview
constructor
A new instance of Preview.
- #text ⇒ Object
Constructor Details
#initialize(context, source) ⇒ Preview
Returns a new instance of Preview.
5 6 7 |
# File 'lib/rpub/preview.rb', line 5 def initialize(context, source) @context, @source = context, source end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/rpub/preview.rb', line 3 def context @context end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/rpub/preview.rb', line 3 def source @source end |
Instance Method Details
#formatted ⇒ Object
9 10 11 12 |
# File 'lib/rpub/preview.rb', line 9 def formatted return unless context.chapter_files.any? move_styles_inline(plain) end |
#text ⇒ Object
14 15 16 |
# File 'lib/rpub/preview.rb', line 14 def text Nokogiri::HTML(plain).xpath('//text()').to_s end |