Module: CbNitride::HasherMethods
- Included in:
- PrivateHasher, PublicHasher
- Defined in:
- lib/cb_nitride/hasher_methods.rb
Instance Attribute Summary collapse
-
#error_array ⇒ Object
Returns the value of attribute error_array.
Instance Method Summary collapse
- #clean_date_string(date) ⇒ Object
- #clean_price_float(price) ⇒ Object
- #find_text_with(code) ⇒ Object
- #get_image_url(base_url, image_class) ⇒ Object
Instance Attribute Details
#error_array ⇒ Object
Returns the value of attribute error_array.
4 5 6 |
# File 'lib/cb_nitride/hasher_methods.rb', line 4 def error_array @error_array end |
Instance Method Details
#clean_date_string(date) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/cb_nitride/hasher_methods.rb', line 33 def clean_date_string(date) if date.nil? || date.empty? error_array << "No Release Date" return nil else Date.strptime(date.match(/\d+[\/]\d+[\/]\d+/).to_s, "%m/%d/%Y") end end |
#clean_price_float(price) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/cb_nitride/hasher_methods.rb', line 24 def clean_price_float(price) if price.nil? error_array << "No price" return nil else price.match(/\d+[.]\d+/).to_s.to_f end end |
#find_text_with(code) ⇒ Object
10 11 12 |
# File 'lib/cb_nitride/hasher_methods.rb', line 10 def find_text_with(code) item_page.css(code).text.strip end |
#get_image_url(base_url, image_class) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/cb_nitride/hasher_methods.rb', line 14 def get_image_url(base_url, image_class) image_container = item_page.css(image_class) if image_container.nil? || image_container.empty? error_array << "No Image" return nil else base_url + item_page.css(image_class).first.attributes["href"].value end end |