Class: Ostructer::OsValue
- Includes:
- Comparable
- Defined in:
- lib/ostructer.rb
Instance Attribute Summary
Attributes inherited from OsBase
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value, logger) ⇒ OsValue
constructor
holds/wraps a string.
- #to_bool ⇒ Object
- #to_i ⇒ Object
- #to_openstruct_pass2 ⇒ Object
- #to_s ⇒ Object
Methods inherited from OsBase
Constructor Details
#initialize(value, logger) ⇒ OsValue
holds/wraps a string
60 61 62 63 64 65 66 |
# File 'lib/ostructer.rb', line 60 def initialize( value, logger ) @value = value @logger = logger @parent = nil @field ="[!unknown_value]" end |
Instance Method Details
#<=>(other) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ostructer.rb', line 74 def <=>(other) if other.is_a? Numeric logger.debug "OsValue <=> Numeric: #{self.to_i} <=> #{other}" self.to_i <=> other elsif other.is_a? String logger.debug "OsValue <=> String: #{self.to_s} <=> #{other}" self.to_s <=> other else logger.debug "OsValue - no <=> defined for type #{other.class}" nil end ## todo: add bool end |
#to_bool ⇒ Object
97 98 99 |
# File 'lib/ostructer.rb', line 97 def to_bool @value == 'true' end |
#to_i ⇒ Object
93 94 95 |
# File 'lib/ostructer.rb', line 93 def to_i @value.to_i end |
#to_openstruct_pass2 ⇒ Object
68 69 70 |
# File 'lib/ostructer.rb', line 68 def to_openstruct_pass2 # do nothing (has no children) end |
#to_s ⇒ Object
89 90 91 |
# File 'lib/ostructer.rb', line 89 def to_s @value end |