Class: Kokkai::Record

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/kokkai/record.rb

Direct Known Subclasses

Meeting, Speech

Constant Summary collapse

DEFAULT_ATTRIBUTES =
i(session name_of_house name_of_meeting issue date meeting_url pdf_url).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Record

Returns a new instance of Record.



32
33
34
35
# File 'lib/kokkai/record.rb', line 32

def initialize(raw)
  @raw = raw
  @raw_record = @raw.dig("recordData")
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



8
9
10
# File 'lib/kokkai/record.rb', line 8

def raw
  @raw
end

#raw_recordObject (readonly)

Returns the value of attribute raw_record.



8
9
10
# File 'lib/kokkai/record.rb', line 8

def raw_record
  @raw_record
end

Class Method Details

.define_attribute_methods(attrs) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kokkai/record.rb', line 13

def define_attribute_methods(attrs)
  attrs.each do |attr|
    define_method(attr) do
      key = attr.to_s
      key = if key.match(/_url$/)
        key = key.split(/_url$/) { |s| s }.join() + ""
        key << "URL"
      else
        key.to_camel
      end
      @raw_record ? @raw_record[key] : nil
    end
    memoize attr
  end
end