Class: Ting::Converter
- Inherits:
-
Object
- Object
- Ting::Converter
- Includes:
- Procable
- Defined in:
- lib/ting/converter.rb
Instance Attribute Summary collapse
-
#from_conv ⇒ Object
readonly
Returns the value of attribute from_conv.
-
#from_tone ⇒ Object
readonly
Returns the value of attribute from_tone.
-
#to_conv ⇒ Object
readonly
Returns the value of attribute to_conv.
-
#to_tone ⇒ Object
readonly
Returns the value of attribute to_tone.
Instance Method Summary collapse
- #convert(str) ⇒ Object (also: #<<, #call)
-
#initialize(from, from_tone, to, to_tone) ⇒ Converter
constructor
A new instance of Converter.
- #reader ⇒ Object
- #to(to, to_tone) ⇒ Object
- #writer ⇒ Object
Methods included from Procable
Constructor Details
#initialize(from, from_tone, to, to_tone) ⇒ Converter
Returns a new instance of Converter.
7 8 9 |
# File 'lib/ting/converter.rb', line 7 def initialize(from, from_tone, to, to_tone) @from_conv, @from_tone, @to_conv, @to_tone = from, from_tone, to, to_tone end |
Instance Attribute Details
#from_conv ⇒ Object (readonly)
Returns the value of attribute from_conv.
5 6 7 |
# File 'lib/ting/converter.rb', line 5 def from_conv @from_conv end |
#from_tone ⇒ Object (readonly)
Returns the value of attribute from_tone.
5 6 7 |
# File 'lib/ting/converter.rb', line 5 def from_tone @from_tone end |
#to_conv ⇒ Object (readonly)
Returns the value of attribute to_conv.
5 6 7 |
# File 'lib/ting/converter.rb', line 5 def to_conv @to_conv end |
#to_tone ⇒ Object (readonly)
Returns the value of attribute to_tone.
5 6 7 |
# File 'lib/ting/converter.rb', line 5 def to_tone @to_tone end |
Instance Method Details
#convert(str) ⇒ Object Also known as: <<, call
19 20 21 |
# File 'lib/ting/converter.rb', line 19 def convert(str) writer.unparse reader.parse(str) end |
#reader ⇒ Object
11 12 13 |
# File 'lib/ting/converter.rb', line 11 def reader @reader ||= Reader.new(from_conv, from_tone) end |