Class: Cortex::Snippets::Webpage
- Inherits:
-
Object
- Object
- Cortex::Snippets::Webpage
- Defined in:
- lib/cortex/snippets/webpage.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #accordion_group_widget_data ⇒ Object
- #accordion_group_widget_data_for(section_name) ⇒ Object
- #buy_box_widget_data ⇒ Object
- #carousels_widget_data ⇒ Object
- #carousels_widget_data_for(section_name) ⇒ Object
- #charts_widget_data ⇒ Object
- #charts_widget_data_for(section_name) ⇒ Object
- #form_configs ⇒ Object
- #galleries_widget_data ⇒ Object
- #galleries_widget_data_for(section_name) ⇒ Object
-
#initialize(cortex_client, url) ⇒ Webpage
constructor
A new instance of Webpage.
- #noarchive ⇒ Object
- #nofollow ⇒ Object
- #noimageindex ⇒ Object
- #noindex ⇒ Object
- #noodp ⇒ Object
- #nosnippet ⇒ Object
- #product_data ⇒ Object
- #seo_description ⇒ Object
- #seo_keywords ⇒ Object
- #seo_robots ⇒ Object
- #seo_title ⇒ Object
- #snippets ⇒ Object
- #tables_widget_data ⇒ Object
- #tables_widget_data_for(section_name) ⇒ Object
Constructor Details
#initialize(cortex_client, url) ⇒ Webpage
Returns a new instance of Webpage.
6 7 8 9 10 11 |
# File 'lib/cortex/snippets/webpage.rb', line 6 def initialize(cortex_client, url) @url = url @response = cortex_client.webpages.get_feed(url) @status = @response.status @contents = @response.contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
4 5 6 |
# File 'lib/cortex/snippets/webpage.rb', line 4 def contents @contents end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/cortex/snippets/webpage.rb', line 4 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/cortex/snippets/webpage.rb', line 4 def status @status end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/cortex/snippets/webpage.rb', line 4 def url @url end |
Instance Method Details
#accordion_group_widget_data ⇒ Object
84 85 86 |
# File 'lib/cortex/snippets/webpage.rb', line 84 def JSON.parse(@contents[:accordion_group_widget_json] || 'null', quirks_mode: true) end |
#accordion_group_widget_data_for(section_name) ⇒ Object
88 89 90 |
# File 'lib/cortex/snippets/webpage.rb', line 88 def (section_name) &.[](section_name) || [] end |
#buy_box_widget_data ⇒ Object
96 97 98 |
# File 'lib/cortex/snippets/webpage.rb', line 96 def JSON.parse(@contents[:buy_box_widget_json] || 'null', quirks_mode: true) end |
#carousels_widget_data ⇒ Object
68 69 70 |
# File 'lib/cortex/snippets/webpage.rb', line 68 def JSON.parse(@contents[:carousels_widget_json] || 'null', quirks_mode: true) end |
#carousels_widget_data_for(section_name) ⇒ Object
72 73 74 |
# File 'lib/cortex/snippets/webpage.rb', line 72 def (section_name) &.[](section_name) end |
#charts_widget_data ⇒ Object
92 93 94 |
# File 'lib/cortex/snippets/webpage.rb', line 92 def JSON.parse(@contents[:charts_widget_json] || 'null', quirks_mode: true) end |
#charts_widget_data_for(section_name) ⇒ Object
100 101 102 |
# File 'lib/cortex/snippets/webpage.rb', line 100 def (section_name) &.[](section_name) || {} end |
#form_configs ⇒ Object
108 109 110 |
# File 'lib/cortex/snippets/webpage.rb', line 108 def form_configs @form_configs ||= JSON.parse(@contents[:form_configs_json] || 'null', quirks_mode: true) end |
#galleries_widget_data ⇒ Object
76 77 78 |
# File 'lib/cortex/snippets/webpage.rb', line 76 def JSON.parse(@contents[:galleries_widget_json] || 'null', quirks_mode: true) end |
#galleries_widget_data_for(section_name) ⇒ Object
80 81 82 |
# File 'lib/cortex/snippets/webpage.rb', line 80 def (section_name) &.[](section_name) end |
#noarchive ⇒ Object
52 53 54 |
# File 'lib/cortex/snippets/webpage.rb', line 52 def noarchive @contents[:noarchive] end |
#nofollow ⇒ Object
40 41 42 |
# File 'lib/cortex/snippets/webpage.rb', line 40 def nofollow @contents[:nofollow] end |
#noimageindex ⇒ Object
56 57 58 |
# File 'lib/cortex/snippets/webpage.rb', line 56 def noimageindex @contents[:noimageindex] end |
#noindex ⇒ Object
36 37 38 |
# File 'lib/cortex/snippets/webpage.rb', line 36 def noindex @contents[:noindex] end |
#noodp ⇒ Object
44 45 46 |
# File 'lib/cortex/snippets/webpage.rb', line 44 def noodp @contents[:noodp] end |
#nosnippet ⇒ Object
48 49 50 |
# File 'lib/cortex/snippets/webpage.rb', line 48 def nosnippet @contents[:nosnippet] end |
#product_data ⇒ Object
104 105 106 |
# File 'lib/cortex/snippets/webpage.rb', line 104 def product_data @product_data ||= JSON.parse(@contents[:product_data_json] || 'null', quirks_mode: true) end |
#seo_description ⇒ Object
17 18 19 |
# File 'lib/cortex/snippets/webpage.rb', line 17 def seo_description @contents[:seo_description] end |
#seo_keywords ⇒ Object
21 22 23 |
# File 'lib/cortex/snippets/webpage.rb', line 21 def seo_keywords @contents[:seo_keyword_list] end |
#seo_robots ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cortex/snippets/webpage.rb', line 25 def seo_robots robot_information = [] = [:noindex, :nofollow, :noodp, :nosnippet, :noarchive, :noimageindex] .each do |index_option| robot_information << index_option if @contents[index_option] end robot_information end |
#seo_title ⇒ Object
13 14 15 |
# File 'lib/cortex/snippets/webpage.rb', line 13 def seo_title @contents[:seo_title] end |
#snippets ⇒ Object
112 113 114 |
# File 'lib/cortex/snippets/webpage.rb', line 112 def snippets @contents[:snippets] end |
#tables_widget_data ⇒ Object
60 61 62 |
# File 'lib/cortex/snippets/webpage.rb', line 60 def JSON.parse(@contents[:tables_widget_json] || 'null', quirks_mode: true) end |
#tables_widget_data_for(section_name) ⇒ Object
64 65 66 |
# File 'lib/cortex/snippets/webpage.rb', line 64 def (section_name) &.[](section_name) || [] end |