Class: ImproveTypography::Base
- Inherits:
-
Struct
- Object
- Struct
- ImproveTypography::Base
- Defined in:
- lib/improve_typography/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#str ⇒ Object
Returns the value of attribute str.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(str, options = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(str, options = {}) ⇒ Base
Returns a new instance of Base.
21 22 23 |
# File 'lib/improve_typography/base.rb', line 21 def initialize(str, = {}) super(str, ) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options
4 5 6 |
# File 'lib/improve_typography/base.rb', line 4 def @options end |
#str ⇒ Object
Returns the value of attribute str
4 5 6 |
# File 'lib/improve_typography/base.rb', line 4 def str @str end |
Class Method Details
.add_processor_class(klass) ⇒ Object
10 11 12 13 14 |
# File 'lib/improve_typography/base.rb', line 10 def add_processor_class(klass) unless all_processor_classes.include?(klass) all_processor_classes << klass end end |
.all_processor_classes ⇒ Object
6 7 8 |
# File 'lib/improve_typography/base.rb', line 6 def all_processor_classes @@all_processor_classes ||= [] end |
.call(*args) ⇒ Object
16 17 18 |
# File 'lib/improve_typography/base.rb', line 16 def call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/improve_typography/base.rb', line 25 def call return str unless processor_classes.count > 0 doc.xpath('.//text()').each do |node| processor_classes.each do |processor| node.content = processor.call(node.content, ) end end CGI.unescapeHTML( doc.to_html.strip[5..-7] ) end |