Class: CbNitride::PrivateHasher
- Inherits:
-
Object
- Object
- CbNitride::PrivateHasher
- Includes:
- HasherMethods
- Defined in:
- lib/cb_nitride/private_hasher.rb
Constant Summary collapse
- BASE_URL =
"https://retailerservices.diamondcomics.com"
- DIAMOND_NUMBER_SEARCH_PATH =
"/ShoppingList/AddItem/"
- SEARCH_URL =
BASE_URL + DIAMOND_NUMBER_SEARCH_PATH
- IMAGE_CLASS =
'a.ImagePopup'
- TITLE_CLASS =
'.ItemDetails_ItemName'
- PUBLISHER_CLASS =
'.ItemDetails_Publisher'
- CREATOR_CLASS =
'.ItemDetails_Creator'
- DESCRIPTION_CLASS =
'.ItemDetails_Description'
- CONTAINER_CLASS =
'.PopupContent'
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#container_class ⇒ Object
readonly
Returns the value of attribute container_class.
-
#diamond_number ⇒ Object
readonly
Returns the value of attribute diamond_number.
-
#image_class ⇒ Object
readonly
Returns the value of attribute image_class.
-
#search_url ⇒ Object
readonly
Returns the value of attribute search_url.
Attributes included from HasherMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(diamond_number, agent = DiamondLogin.agent) ⇒ PrivateHasher
constructor
A new instance of PrivateHasher.
- #spawn_item ⇒ Object
- #valid_diamond_number? ⇒ Boolean
Methods included from HasherMethods
#clean_date_string, #clean_price_float, #find_text_with, #get_image_url
Constructor Details
#initialize(diamond_number, agent = DiamondLogin.agent) ⇒ PrivateHasher
Returns a new instance of PrivateHasher.
28 29 30 31 |
# File 'lib/cb_nitride/private_hasher.rb', line 28 def initialize(diamond_number, agent = DiamondLogin.agent) @diamond_number = diamond_number @agent = agent end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
5 6 7 |
# File 'lib/cb_nitride/private_hasher.rb', line 5 def agent @agent end |
#container_class ⇒ Object (readonly)
Returns the value of attribute container_class.
5 6 7 |
# File 'lib/cb_nitride/private_hasher.rb', line 5 def container_class @container_class end |
#diamond_number ⇒ Object (readonly)
Returns the value of attribute diamond_number.
5 6 7 |
# File 'lib/cb_nitride/private_hasher.rb', line 5 def diamond_number @diamond_number end |
#image_class ⇒ Object (readonly)
Returns the value of attribute image_class.
5 6 7 |
# File 'lib/cb_nitride/private_hasher.rb', line 5 def image_class @image_class end |
#search_url ⇒ Object (readonly)
Returns the value of attribute search_url.
5 6 7 |
# File 'lib/cb_nitride/private_hasher.rb', line 5 def search_url @search_url end |
Class Method Details
.item(diamond_number, agent = DiamondLogin.agent) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cb_nitride/private_hasher.rb', line 19 def self.item(diamond_number, agent = DiamondLogin.agent) item = new(diamond_number, agent) if item.valid_diamond_number? item.spawn_item else return NullItem.new(diamond_number) end end |
Instance Method Details
#spawn_item ⇒ Object
33 34 35 |
# File 'lib/cb_nitride/private_hasher.rb', line 33 def spawn_item DiamondItem.new(branded_hash) end |
#valid_diamond_number? ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/cb_nitride/private_hasher.rb', line 37 def valid_diamond_number? if item_page.css(CONTAINER_CLASS).empty? return false else return true end end |