Class: Semi::Variables::Integer

Inherits:
Base
  • Object
show all
Defined in:
lib/semi/variables/integer.rb

Class Method Summary collapse

Instance Method Summary collapse

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



19
20
21
# File 'lib/semi/variables/integer.rb', line 19

def method_missing(m, *args, &block)
  @value.to_i.send(m, *args, &block)
end

Class Method Details

.validate(value) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/semi/variables/integer.rb', line 10

def self.validate(value)
  if value.class == 1.class
    return true
  elsif value.class == Semi::Variables::Integer and value.to_s =~ /^\d+$/
    return true
  end
  false
end

Instance Method Details

#validateObject



6
7
8
# File 'lib/semi/variables/integer.rb', line 6

def validate
  self.validate(@value)
end