Sha256: d157c9015f1951ed1e9ce9d68630e8c40958edc575ce880aad3ab593c061f9eb

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

module Twfy

  class MP < DataElement

    convert_to_date :entered_house, :left_house

    convert :image do |value|
      URI.parse("https://theyworkforyou.com#{value}")
    end

    convert :constituency do |source, value|
      if value.is_a?(Constituency)
        value
      else
        Constituency.new(source.client, name: value, mp: source)
      end
    end

    def in_office?
      @left_reason == 'still_in_office'
    end

    def info
      @info ||= @client.mp_info(id: @person_id)
    end

    def debates(params={})
      @debates ||= {}
      @debates[params] ||= @client.debates(params.merge(person: @person_id, type: 'commons'))
    end

    def comments(params={})
      @comments ||= {}
      @comments[params] ||= @client.comments(params.merge(pid: @person_id))
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twfy-1.1.1 lib/twfy/mp.rb