Class: TimeDateMatcher

Inherits:
Object show all
Defined in:
lib/core_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ TimeDateMatcher

Returns a new instance of TimeDateMatcher.


10
11
12
# File 'lib/core_extensions.rb', line 10

def initialize(instance)
  @instance = instance
end

Instance Attribute Details

#instanceObject (readonly)

Returns the value of attribute instance


9
10
11
# File 'lib/core_extensions.rb', line 9

def instance
  @instance
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/core_extensions.rb', line 13

def ==(other)
  # allow nils to match
  return true if other.nil?
  # attempt to parse any strings
  if other.is_a?(String)
    begin
      other = self.instance.class.parse(other)
    rescue => e
      return false
    end
  end
  self.instance.class == other.class
end