Class: ChromeStoreSearch::App

Inherits:
Object
  • Object
show all
Defined in:
lib/chrome_store_search/app.rb

Constant Summary collapse

APP_DETAIL_BASE_URL =
"https://chrome.google.com/webstore/ajax/detail?"
DEFAULT_PARAMETER =
{:hl =>"en-US"}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ App

Returns a new instance of App.



16
17
18
# File 'lib/chrome_store_search/app.rb', line 16

def initialize(id=nil)
  update_detail_info(id) if id
end

Instance Attribute Details

#big_logo_urlObject

Returns the value of attribute big_logo_url.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def big_logo_url
  @big_logo_url
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def description
  @description
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def id
  @id
end

#imagesObject

Returns the value of attribute images.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def images
  @images
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def name
  @name
end

#ratingObject

Returns the value of attribute rating.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def rating
  @rating
end

#short_descriptionObject

Returns the value of attribute short_description.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def short_description
  @short_description
end

#siteObject

Returns the value of attribute site.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def site
  @site
end

#small_logo_urlObject

Returns the value of attribute small_logo_url.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def small_logo_url
  @small_logo_url
end

#support_urlObject

Returns the value of attribute support_url.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def support_url
  @support_url
end

#total_rating_countObject

Returns the value of attribute total_rating_count.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def total_rating_count
  @total_rating_count
end

#total_usersObject

Returns the value of attribute total_users.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def total_users
  @total_users
end

#updated_atObject

Returns the value of attribute updated_at.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def updated_at
  @updated_at
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def url
  @url
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def version
  @version
end

#videosObject

Returns the value of attribute videos.



7
8
9
# File 'lib/chrome_store_search/app.rb', line 7

def videos
  @videos
end

Instance Method Details

#set_basic_info(app_item) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/chrome_store_search/app.rb', line 30

def set_basic_info(app_item)
  self.id = app_item[0]
  self.name = app_item[1]
  self.small_logo_url = app_item[3].encode("UTF-8")
  self.short_description = app_item[6]
  self.rating = app_item[12]
  self.total_rating_count = app_item[22].to_i
  self.total_users = app_item[23].gsub(",", "").to_i
  self.big_logo_url = app_item[25].encode("UTF-8")
  self.url = app_item[37]
end

#update_detail_info(id, parmeter = DEFAULT_PARAMETER) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/chrome_store_search/app.rb', line 20

def update_detail_info(id, parmeter = DEFAULT_PARAMETER)
  @parmeter = DEFAULT_PARAMETER.merge(parmeter)
  conn = Faraday.new(:url => init_detail_url(id)) do |faraday|
    faraday.request  :url_encoded
    faraday.adapter  Faraday.default_adapter
  end
  res = conn.post '', {}
  parse_detail(res.body)
end