Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/aaron/extensions.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/aaron/extensions.rb', line 27

def method_missing m, *args, &block
  if /(.+)s$/.match(m.to_s) and self.respond_to?($1) # support for seconds, minutes etc
    self.send($1)
  else
    super
  end
end

Instance Method Details

#dayObject



19
20
21
# File 'lib/aaron/extensions.rb', line 19

def day
  hour * 24
end

#hourObject



15
16
17
# File 'lib/aaron/extensions.rb', line 15

def hour
  minute * 60
end

#minuteObject



11
12
13
# File 'lib/aaron/extensions.rb', line 11

def minute
  second * 60
end

#secondObject



7
8
9
# File 'lib/aaron/extensions.rb', line 7

def second
  self
end

#to(other) ⇒ Object



3
4
5
# File 'lib/aaron/extensions.rb', line 3

def to other
  (self..other)
end

#weekObject



23
24
25
# File 'lib/aaron/extensions.rb', line 23

def week
  day * 7
end