Class: Parse::Date
- Inherits:
-
Object
show all
- Defined in:
- lib/parse/datatypes.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Date
Returns a new instance of Date.
72
73
74
75
76
77
78
79
80
|
# File 'lib/parse/datatypes.rb', line 72
def initialize(data)
if data.is_a? DateTime
@value = data
elsif data.is_a? Hash
@value = DateTime.parse data["iso"]
elsif data.is_a? String
@value = DateTime.parse data
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/parse/datatypes.rb', line 97
def method_missing(method, *args, &block)
if value.respond_to?(method)
value.send(method, *args, &block)
else
super(method)
end
end
|
Instance Attribute Details
Returns the value of attribute value.
70
71
72
|
# File 'lib/parse/datatypes.rb', line 70
def value
@value
end
|
Instance Method Details
#<=>(other) ⇒ Object
93
94
95
|
# File 'lib/parse/datatypes.rb', line 93
def <=>(other)
value <=> other.value
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
82
83
84
85
|
# File 'lib/parse/datatypes.rb', line 82
def eql?(other)
self.class.equal?(other.class) &&
value == other.value
end
|
89
90
91
|
# File 'lib/parse/datatypes.rb', line 89
def hash
value.hash
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
105
106
107
|
# File 'lib/parse/datatypes.rb', line 105
def respond_to?(method, include_private = false)
super || value.respond_to?(method, include_private)
end
|
#to_json(*a) ⇒ Object
116
117
118
|
# File 'lib/parse/datatypes.rb', line 116
def to_json(*a)
as_json.to_json(*a)
end
|