Class: Unpatched::NormalWrapper
Instance Method Summary
collapse
Methods inherited from Wrapper
#and, const_missing, #initialize, #inspect
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *a, &b) ⇒ Object
137
138
139
140
141
142
143
144
145
|
# File 'lib/unpatched.rb', line 137
def method_missing(m, *a, &b)
a.map! { |e| Utils.unwrapped e }
if m[-1] == ?! and NormalWrapper.method_defined?(method = m[0..-2])
result = __send__(method, *a, &b)
Utils.unwrapped result
else
Utils.wrapped @value.__send__(m, *a, &b)
end
end
|
Instance Method Details
#ago ⇒ Object
120
121
122
|
# File 'lib/unpatched.rb', line 120
def ago
before Time.now
end
|
#day ⇒ Object
Also known as:
days
#from_now ⇒ Object
125
126
127
|
# File 'lib/unpatched.rb', line 125
def from_now
after Time.now
end
|
#hour ⇒ Object
Also known as:
hours
#minute ⇒ Object
Also known as:
minutes
#month ⇒ Object
Also known as:
months
#second ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/unpatched.rb', line 84
def second
value = Utils.unwrapped @value
if value.respond_to? :second
value.second
else
Utils.wrapped Utils.num(value)
end
rescue TypeError, ArgumentError => err
raise err unless value.respond_to? :[]
value[1]
end
|
#seconds ⇒ Object
105
|
# File 'lib/unpatched.rb', line 105
def seconds; Utils.wrapped Utils.num(@value) end
|
#underscore ⇒ Object
96
97
98
99
100
101
102
103
|
# File 'lib/unpatched.rb', line 96
def underscore
to_s.
gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
|
#year ⇒ Object
Also known as:
years