Class: ClickClient::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/clickclient/common.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(item) ⇒ Base
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/clickclient/common.rb', line 122
def initialize( item )
item.attributes.each { |name, value|
set_attribute(name.to_s ,value)
}
item.elements.each { |elm|
if ( elm.name != "responseStatus" && elm.name != "message" )
set_attribute(elm.name.to_s, elm.text)
end
}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/clickclient/common.rb', line 140
def method_missing( name, *args )
if name.to_s =~ /(.*?)=/
name = $1
setter = true
end
value = instance_variable_get("@" << name.to_s)
unless ( value == nil )
if setter
instance_variable_set( "@" << name, args[0] )
else
return value
end
else
super(name)
end
end
|
Instance Method Details
#eql?(other) ⇒ Boolean
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/clickclient/common.rb', line 165
def eql?(other)
return false if other == nil
return false unless other.is_a?( Base )
a = values
b = other.values
return false if a.length != b.length
a.length.times{|i|
return false unless a[i].eql? b[i]
}
return true
end
|
#hash ⇒ Object
158
159
160
161
162
163
164
|
# File 'lib/clickclient/common.rb', line 158
def hash
hash = 0
values.each {|v|
hash = v.hash + 31 * hash
}
return hash
end
|
#to_s ⇒ Object
133
134
135
136
137
138
139
|
# File 'lib/clickclient/common.rb', line 133
def to_s
str = ""
instance_variables.each { |name|
str += name + "=" + instance_variable_get(name).to_s + ", "
}
return str.chop.chop
end
|