Class: OrderLastReview
- Inherits:
-
Object
- Object
- OrderLastReview
- Defined in:
- lib/order_payment.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
Instance Method Summary collapse
-
#initialize(doc) ⇒ OrderLastReview
constructor
A new instance of OrderLastReview.
- #to_s ⇒ Object
Constructor Details
#initialize(doc) ⇒ OrderLastReview
Returns a new instance of OrderLastReview.
88 89 90 |
# File 'lib/order_payment.rb', line 88 def initialize(doc) self.doc = doc end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
86 87 88 |
# File 'lib/order_payment.rb', line 86 def doc @doc end |
Instance Method Details
#to_s ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/order_payment.rb', line 92 def to_s sections = doc.css(".l-section").map do |section| next unless section.css(".m-heading__caption").count > 0 section_name = section.css(".m-heading__caption").text.strip.gsub(/\s+/, " ").colorize(:green) rows = section.css("tr").map do |row| th = row.css(".m-input__heading").first || row.css("th").first th_text = th.text.strip.gsub(/\s+/, " ").colorize(:blue) td_text = row.css(".section_content_table_td").text. gsub(/ +/, " ").gsub(/\t+/, "").gsub(/(?:\r\n)+/, "\r\n").strip "#{th_text}\n#{td_text}" end "\n#{section_name}\n#{rows.join("\n")}" end sections.join("\n") end |