Class: Tellstick::CodeConverter
- Inherits:
-
Object
- Object
- Tellstick::CodeConverter
- Defined in:
- lib/tellstick/code_converter.rb
Overview
Validates and converts code string to a positive integer Uses an array patters to validate code against
Instance Method Summary collapse
-
#initialize(patterns, integer_offset = 0) ⇒ CodeConverter
constructor
A new instance of CodeConverter.
- #to_i(code) ⇒ Object
Constructor Details
#initialize(patterns, integer_offset = 0) ⇒ CodeConverter
Returns a new instance of CodeConverter.
21 22 23 24 |
# File 'lib/tellstick/code_converter.rb', line 21 def initialize(patterns,integer_offset=0) @patterns = patterns @integer_offset = integer_offset end |
Instance Method Details
#to_i(code) ⇒ Object
26 27 28 29 |
# File 'lib/tellstick/code_converter.rb', line 26 def to_i(code) choices = %w{integer_str upcase_str lowcase_str} self.class.send(choices[find_parser(code)],code,@integer_offset) end |