Module: Keisan::AST::DateTimeMethods

Included in:
Date, Time
Defined in:
lib/keisan/ast/date_time_methods.rb

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/keisan/ast/date_time_methods.rb', line 4

def +(other)
  other = other.to_node
  case other
  when Number
    self.class.new(value + other.value)
  else
    super
  end
end

#<(other) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/keisan/ast/date_time_methods.rb', line 24

def <(other)
  other = other.to_node
  case other
  when self.class
    Boolean.new(value.to_time < other.value.to_time)
  else
    super
  end
end

#<=(other) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/keisan/ast/date_time_methods.rb', line 44

def <=(other)
  other = other.to_node
  case other
  when self.class
    Boolean.new(value.to_time <= other.value.to_time)
  else
    super
  end
end

#>(other) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/keisan/ast/date_time_methods.rb', line 14

def >(other)
  other = other.to_node
  case other
  when self.class
    Boolean.new(value.to_time > other.value.to_time)
  else
    super
  end
end

#>=(other) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/keisan/ast/date_time_methods.rb', line 34

def >=(other)
  other = other.to_node
  case other
  when self.class
    Boolean.new(value.to_time >= other.value.to_time)
  else
    super
  end
end

#equal(other) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/keisan/ast/date_time_methods.rb', line 54

def equal(other)
  other = other.to_node
  case other
  when self.class
    Boolean.new(value.to_time == other.value.to_time)
  else
    super
  end
end

#not_equal(other) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/keisan/ast/date_time_methods.rb', line 64

def not_equal(other)
  other = other.to_node
  case other
  when self.class
    Boolean.new(value.to_time != other.value.to_time)
  else
    super
  end
end