Class: Side
- Inherits:
-
Object
- Object
- Side
- Defined in:
- lib/side.rb,
lib/side.rb
Defined Under Namespace
Classes: Combo
Instance Attribute Summary collapse
-
#allergen_warning ⇒ Object
Returns the value of attribute allergen_warning.
-
#category_id ⇒ Object
Returns the value of attribute category_id.
-
#combo ⇒ Object
Returns the value of attribute combo.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #available_combos ⇒ Object
- #customizable? ⇒ Boolean
-
#initialize(element) ⇒ Side
constructor
A new instance of Side.
- #list_item ⇒ Object
- #params ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(element) ⇒ Side
Returns a new instance of Side.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/side.rb', line 21 def initialize(element) return unless element["iname"] link = element["href"] parts = link.split("/") side_id = parts.pop category_id = parts.pop # some_other_number = parts.pop # TODO: figure out what this is description = element.css(".menu_itemList_item_text").first description = description.text if description allergen_warning = element.css(".js-menuSetHeight_allergen").first allergen_warning = allergen_warning.text if allergen_warning self.url = "https://order.dominos.jp#{link}" self.id = side_id # shohinC self.category_id = category_id # categoryC self.name = element["iname"] self.description = description self.allergen_warning = allergen_warning end |
Instance Attribute Details
#allergen_warning ⇒ Object
Returns the value of attribute allergen_warning.
18 19 20 |
# File 'lib/side.rb', line 18 def allergen_warning @allergen_warning end |
#category_id ⇒ Object
Returns the value of attribute category_id.
18 19 20 |
# File 'lib/side.rb', line 18 def category_id @category_id end |
#combo ⇒ Object
Returns the value of attribute combo.
19 20 21 |
# File 'lib/side.rb', line 19 def combo @combo end |
#description ⇒ Object
Returns the value of attribute description.
18 19 20 |
# File 'lib/side.rb', line 18 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
18 19 20 |
# File 'lib/side.rb', line 18 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/side.rb', line 18 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
18 19 20 |
# File 'lib/side.rb', line 18 def url @url end |
Instance Method Details
#available_combos ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/side.rb', line 52 def available_combos @available_combos ||= detail_page_content.css(".m-section_item__changeSide .m-input__radio").map do |option| Side::Combo.new(option) end @available_combos.sort_by! { |cmb| cmb.default ? 0 : 1 } end |
#customizable? ⇒ Boolean
48 49 50 |
# File 'lib/side.rb', line 48 def customizable? available_combos.count > 0 end |
#list_item ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/side.rb', line 69 def list_item allergen = allergen_warning || "" "#{name.colorize(:blue)} "\ "#{allergen.strip.colorize(:yellow)}\n "\ "#{description.gsub(",", ", ").gsub(")", ") ")}\n".sub("\n \n", "") end |
#params ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/side.rb', line 61 def params { "shohinC" => id, "categoryC" => category_id, "setRecommendYosoData" => combo.value } end |
#valid? ⇒ Boolean
44 45 46 |
# File 'lib/side.rb', line 44 def valid? url != nil end |