Class: ROC::Integer

Inherits:
Base
  • Object
show all
Includes:
Types::ScalarType
Defined in:
lib/roc/objects/integer.rb

Instance Attribute Summary

Attributes inherited from Base

#key, #options

Instance Method Summary collapse

Methods included from Types::ScalarType

#clobber, #inspect, #setex

Methods included from Types::MethodGenerators

#deserializing_method, #nonserializing_method, #serializing_and_deserializing_method, #serializing_method, #zero_arg_method

Methods inherited from Base

#clobber, delegate_methods, #initialize, #method_missing, #respond_to?, #seed

Methods included from Types::AllTypes

#eval

Constructor Details

This class inherits a constructor from ROC::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ROC::Base

Instance Method Details

#decrement(by = nil) ⇒ Object Also known as: decr, decrby



26
27
28
29
30
31
32
# File 'lib/roc/objects/integer.rb', line 26

def decrement(by=nil)
  if by.nil?
    self.call :decr
  else
    self.call :decrby, by
  end
end

#deserialize(val) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/roc/objects/integer.rb', line 42

def deserialize(val)
  if val.nil?
    nil
  else
    val.to_i
  end
end

#increment(by = nil) ⇒ Object Also known as: incr, incrby

implemeting redis methods ##



16
17
18
19
20
21
22
# File 'lib/roc/objects/integer.rb', line 16

def increment(by=nil)
  if by.nil?
    self.call :incr
  else
    self.call :incrby, by
  end
end

#serialize(val) ⇒ Object

implementing scalar type required methods ##



38
39
40
# File 'lib/roc/objects/integer.rb', line 38

def serialize(val)
  val.to_s
end

#to_integerObject Also known as: to_int, to_i



8
9
10
# File 'lib/roc/objects/integer.rb', line 8

def to_integer
  self.value.to_i
end