Class: Semi::Variables::Integer
- Defined in:
- lib/semi/variables/integer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #method_missing(m, *args, &block) ⇒ Object
-
#validate ⇒ Object
def set(val) # test to see if the value is a common true value if value =~ /true|yes|enable/i @value = true elsif value =~ /false|no|disable/i @value = false else raise Semi::VariableError, “#val trying to be set as a boolean” end end.
Methods inherited from Base
#!=, #!~, #&, #<=>, #==, #===, #=~, #^, #eql?, #equal?, #initialize, #set, #to_s, #value, #|
Constructor Details
This class inherits a constructor from Semi::Variables::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
30 31 32 |
# File 'lib/semi/variables/integer.rb', line 30 def method_missing(m, *args, &block) @value.to_i.send(m, *args, &block) end |
Class Method Details
Instance Method Details
#validate ⇒ Object
def set(val)
# test to see if the value is a common true value
if value =~ /true|yes|enable/i
@value = true
elsif value =~ /false|no|disable/i
@value = false
else
raise Semi::VariableError, "#{val} trying to be set as a boolean"
end
end
17 18 19 |
# File 'lib/semi/variables/integer.rb', line 17 def validate self.validate(@value) end |