Class: FederalRegister::Base
- Inherits:
-
Client
- Object
- Client
- FederalRegister::Base
show all
- Defined in:
- lib/federal_register/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Client
get
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Base
Returns a new instance of Base.
36
37
38
39
|
# File 'lib/federal_register/base.rb', line 36
def initialize(attributes = {}, options = {})
@attributes = attributes
@full = options[:full] || false
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
2
3
4
|
# File 'lib/federal_register/base.rb', line 2
def attributes
@attributes
end
|
Class Method Details
.add_attribute(*attributes) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/federal_register/base.rb', line 4
def self.add_attribute(*attributes)
options = {}
if attributes.last.is_a?(Hash)
options = attributes.pop
end
attributes.each do |attr|
define_method attr do
val = @attributes[attr.to_s]
if val
case options[:type]
when :date
if ! val.is_a?(Date)
val = Date.strptime(val.to_s)
end
when :datetime
if ! val.is_a?(DateTime)
val = DateTime.parse(val.to_s)
end
when :integer
if ! val.is_a?(Fixnum)
val = val.to_i
end
end
end
val
end
end
end
|
.override_base_uri(uri) ⇒ Object
Instance Method Details
#fetch_full ⇒ Object
45
46
47
48
49
|
# File 'lib/federal_register/base.rb', line 45
def fetch_full
@attributes = self.class.get(json_url)
@full = true
self
end
|
#full? ⇒ Boolean
41
42
43
|
# File 'lib/federal_register/base.rb', line 41
def full?
@full
end
|