Class: StandaloneTypograf::Typograf
- Inherits:
-
Object
- Object
- StandaloneTypograf::Typograf
- Defined in:
- lib/standalone_typograf.rb
Overview
Options
-
mode [Symbol] typograf supports html and </b>utf</b> mods. The default one is UTF. It means all special symbols will be represents as UTF sequence.
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #exclude(list) ⇒ Object
-
#initialize(text, options = {}) ⇒ Typograf
constructor
A new instance of Typograf.
- #prepare ⇒ String
-
#processor(*names) ⇒ String
Call a separate processor or several processors.
- #processors ⇒ Hash
Constructor Details
#initialize(text, options = {}) ⇒ Typograf
Returns a new instance of Typograf.
50 51 52 53 54 55 |
# File 'lib/standalone_typograf.rb', line 50 def initialize(text, ={}) .assert_valid_keys(:mode, :exclude) @text = text @mode = validate_option([:mode].try(:to_sym), in: [:html, :utf]) || :utf exclude([:exclude]) if [:exclude].present? end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
48 49 50 |
# File 'lib/standalone_typograf.rb', line 48 def mode @mode end |
#text ⇒ Object
Returns the value of attribute text.
47 48 49 |
# File 'lib/standalone_typograf.rb', line 47 def text @text end |
Instance Method Details
#exclude(list) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/standalone_typograf.rb', line 77 def exclude(list) list = Array(list) unless list.is_a?(Array) list.each do |name| validate_option(name, in: processors.keys) processors.delete(name) end end |
#prepare ⇒ String
73 74 75 |
# File 'lib/standalone_typograf.rb', line 73 def prepare processor(*processors.keys) end |
#processor(*names) ⇒ String
Call a separate processor or several processors
59 60 61 62 63 64 65 |
# File 'lib/standalone_typograf.rb', line 59 def processor(*names) names.each do |name| validate_option(name, in: processors.keys) processors[name].send(:compile, text, mode) end return text end |
#processors ⇒ Hash
68 69 70 |
# File 'lib/standalone_typograf.rb', line 68 def processors @processors ||= StandaloneTypograf.processors.deep_dup end |