Class: Asuka::LineFormatter
- Inherits:
-
Object
- Object
- Asuka::LineFormatter
- Defined in:
- lib/asuka/line_formatter.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #format(line) ⇒ Object
-
#initialize(formatter, *steps) ⇒ LineFormatter
constructor
A new instance of LineFormatter.
Constructor Details
#initialize(formatter, *steps) ⇒ LineFormatter
Returns a new instance of LineFormatter.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/asuka/line_formatter.rb', line 5 def initialize(formatter, *steps) steps = steps.flatten if steps.empty? && formatter.respond_to?(:default_steps) @steps = formatter.default_steps else @steps = steps end @formatter = formatter end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
3 4 5 |
# File 'lib/asuka/line_formatter.rb', line 3 def formatter @formatter end |
#steps ⇒ Object
Returns the value of attribute steps.
3 4 5 |
# File 'lib/asuka/line_formatter.rb', line 3 def steps @steps end |
Instance Method Details
#format(line) ⇒ Object
17 18 19 |
# File 'lib/asuka/line_formatter.rb', line 17 def format(line) steps.inject(line) { |line, step| formatter.send(step, line) } end |