Sha256: 4a12014159efba0aec05181a14373a25d00c106b2dc24c14c3afffb70762c5e3

Contents?: true

Size: 723 Bytes

Versions: 6

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true
require 'memoist'

module PhoneSites
  module GsmArena
    class PhoneModel < PhoneSites::PhoneModel
      extend ::Memoist

      ITEMS_PER_PAGE = 40

      def parse(data, attr_name)
        case attr_name
        when :name
          data.children.last.text
        when :url
          data.attribute("href").text
        when :picture_url
          data.css("img").attribute("src").text
        when :description
          data.css("img").attribute("title").text
        else
          raise NotImplementedError
        end
      end

      def info
        ModelInfoResponse.new.perform(URI.join(PhoneSites::GsmArena::BASE_URL, url).to_s)
      end

      memoize :info
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
phone_sites-0.1.2 lib/phone_sites/gsm_arena/phone_model.rb
phone_sites-0.1.1 lib/phone_sites/gsm_arena/phone_model.rb
phone_sites-0.1.0 lib/phone_sites/gsm_arena/phone_model.rb
phone_sites-0.0.5 lib/phone_sites/gsm_arena/phone_model.rb
phone_sites-0.0.5a lib/phone_sites/gsm_arena/phone_model.rb
phone_sites-0.0.4 lib/phone_sites/gsm_arena/phone_model.rb