Class: FDIC::BankFind::Record
- Inherits:
-
Object
- Object
- FDIC::BankFind::Record
show all
- Defined in:
- lib/fdic/bank_find/record.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes) ⇒ Record
Returns a new instance of Record.
4
5
6
7
|
# File 'lib/fdic/bank_find/record.rb', line 4
def initialize(attributes)
@attributes = attributes
@attributes.freeze
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9
10
11
|
# File 'lib/fdic/bank_find/record.rb', line 9
def attributes
@attributes
end
|
Class Method Details
.currency_field(method_name, response_key = method_name) ⇒ Object
23
24
25
26
27
|
# File 'lib/fdic/bank_find/record.rb', line 23
def self.currency_field(method_name, response_key=method_name)
field(method_name, response_key) { |value|
value.to_f * 1000
}
end
|
.date_field(method_name, response_key = method_name) ⇒ Object
29
30
31
32
33
|
# File 'lib/fdic/bank_find/record.rb', line 29
def self.date_field(method_name, response_key=method_name)
field(method_name, response_key) { |value|
Date.parse(value)
}
end
|
.field(method_name, response_key = method_name, &munger) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/fdic/bank_find/record.rb', line 11
def self.field(method_name, response_key=method_name, &munger)
munger ||= lambda { |x| x }
define_method(method_name) {
value = attributes[response_key.to_s]
value && munger.call(value)
}
end
|
.int_field(method_name, response_key = method_name) ⇒ Object
19
20
21
|
# File 'lib/fdic/bank_find/record.rb', line 19
def self.int_field(method_name, response_key=method_name)
field(method_name, response_key, &:to_i)
end
|