Class: DateTime
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(*args, &block) ⇒ DateTime
constructor
A new instance of DateTime.
- #to_date ⇒ Object
- #to_time ⇒ Object
Methods inherited from Date
Constructor Details
#initialize(*args, &block) ⇒ DateTime
Returns a new instance of DateTime.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/glimmer-dsl-opal/ext/date.rb', line 5 def initialize(*args, &block) @time = Time.new(*args, &block) methods_to_exclude = [:to_date, :to_time, :==, :eql?, :class] + Object.new.methods methods_to_define = @time.methods - methods_to_exclude methods_to_define.each do |method_name| singleton_class.define_method(method_name) do |*args, &block| @time.send(method_name, *args, &block) end end end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
24 25 26 27 28 29 30 31 32 |
# File 'lib/glimmer-dsl-opal/ext/date.rb', line 24 def ==(other) return false if other.class != self.class year == other.year and month == other.month and day == other.day and hour == other.hour and min == other.min and sec == other.sec end |
#to_date ⇒ Object
16 17 18 |
# File 'lib/glimmer-dsl-opal/ext/date.rb', line 16 def to_date @time.to_date end |
#to_time ⇒ Object
20 21 22 |
# File 'lib/glimmer-dsl-opal/ext/date.rb', line 20 def to_time @time end |