Class: Parsenum::Parser
- Inherits:
-
Object
- Object
- Parsenum::Parser
- Defined in:
- lib/parsenum/parser.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #currency ⇒ Object
- #currency? ⇒ Boolean
- #float? ⇒ Boolean
-
#initialize(source, type = nil) ⇒ Parser
constructor
A new instance of Parser.
- #integer? ⇒ Boolean
- #nil? ⇒ Boolean
- #percentage? ⇒ Boolean
Constructor Details
#initialize(source, type = nil) ⇒ Parser
4 5 6 7 8 9 |
# File 'lib/parsenum/parser.rb', line 4 def initialize(source, type=nil) @source = source @value = nil @type = nil run end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
2 3 4 |
# File 'lib/parsenum/parser.rb', line 2 def source @source end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/parsenum/parser.rb', line 2 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
2 3 4 |
# File 'lib/parsenum/parser.rb', line 2 def value @value end |
Instance Method Details
#currency ⇒ Object
11 12 13 14 15 16 |
# File 'lib/parsenum/parser.rb', line 11 def currency return nil unless type == Parsenum::CURRENCY return 'GBP' if @source =~ /£/ return 'USD' if @source =~ /\$/ "other" end |
#currency? ⇒ Boolean
26 27 28 |
# File 'lib/parsenum/parser.rb', line 26 def currency? @type == Parsenum::CURRENCY end |
#float? ⇒ Boolean
30 31 32 |
# File 'lib/parsenum/parser.rb', line 30 def float? @type == Parsenum::FLOAT end |
#integer? ⇒ Boolean
34 35 36 |
# File 'lib/parsenum/parser.rb', line 34 def integer? @type == Parsenum::INTEGER end |
#nil? ⇒ Boolean
18 19 20 |
# File 'lib/parsenum/parser.rb', line 18 def nil? @type == Parsenum::NIL end |
#percentage? ⇒ Boolean
22 23 24 |
# File 'lib/parsenum/parser.rb', line 22 def percentage? @type == Parsenum::PERCENTAGE end |