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
- #card_group_widget_data ⇒ Object
- #card_group_widget_data_for(section_name) ⇒ 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
- #slider_widget_data ⇒ Object
- #slider_widget_data_for(section_name) ⇒ 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
101 102 103 |
# File 'lib/cortex/snippets/webpage.rb', line 101 def JSON.parse(@contents[:accordion_group_widget_json] || 'null', quirks_mode: true) end |
#accordion_group_widget_data_for(section_name) ⇒ Object
105 106 107 |
# File 'lib/cortex/snippets/webpage.rb', line 105 def (section_name) &.[](section_name) || [] end |
#buy_box_widget_data ⇒ Object
113 114 115 |
# File 'lib/cortex/snippets/webpage.rb', line 113 def JSON.parse(@contents[:buy_box_widget_json] || 'null', quirks_mode: true) end |
#card_group_widget_data ⇒ Object
93 94 95 |
# File 'lib/cortex/snippets/webpage.rb', line 93 def JSON.parse(@contents[:card_group_widget_json] || 'null', quirks_mode: true) end |
#card_group_widget_data_for(section_name) ⇒ Object
97 98 99 |
# File 'lib/cortex/snippets/webpage.rb', line 97 def (section_name) &.[](section_name) end |
#carousels_widget_data ⇒ Object
69 70 71 |
# File 'lib/cortex/snippets/webpage.rb', line 69 def JSON.parse(@contents[:carousels_widget_json] || 'null', quirks_mode: true) end |
#carousels_widget_data_for(section_name) ⇒ Object
73 74 75 |
# File 'lib/cortex/snippets/webpage.rb', line 73 def (section_name) &.[](section_name) end |
#charts_widget_data ⇒ Object
109 110 111 |
# File 'lib/cortex/snippets/webpage.rb', line 109 def JSON.parse(@contents[:charts_widget_json] || 'null', quirks_mode: true) end |
#charts_widget_data_for(section_name) ⇒ Object
117 118 119 |
# File 'lib/cortex/snippets/webpage.rb', line 117 def (section_name) &.[](section_name) || {} end |
#form_configs ⇒ Object
125 126 127 |
# File 'lib/cortex/snippets/webpage.rb', line 125 def form_configs @form_configs ||= JSON.parse(@contents[:form_configs_json] || 'null', quirks_mode: true) end |
#galleries_widget_data ⇒ Object
77 78 79 |
# File 'lib/cortex/snippets/webpage.rb', line 77 def JSON.parse(@contents[:galleries_widget_json] || 'null', quirks_mode: true) end |
#galleries_widget_data_for(section_name) ⇒ Object
81 82 83 |
# File 'lib/cortex/snippets/webpage.rb', line 81 def (section_name) &.[](section_name) end |
#noarchive ⇒ Object
53 54 55 |
# File 'lib/cortex/snippets/webpage.rb', line 53 def noarchive @contents[:noarchive] end |
#nofollow ⇒ Object
41 42 43 |
# File 'lib/cortex/snippets/webpage.rb', line 41 def nofollow @contents[:nofollow] end |
#noimageindex ⇒ Object
57 58 59 |
# File 'lib/cortex/snippets/webpage.rb', line 57 def noimageindex @contents[:noimageindex] end |
#noindex ⇒ Object
37 38 39 |
# File 'lib/cortex/snippets/webpage.rb', line 37 def noindex @contents[:noindex] end |
#noodp ⇒ Object
45 46 47 |
# File 'lib/cortex/snippets/webpage.rb', line 45 def noodp @contents[:noodp] end |
#nosnippet ⇒ Object
49 50 51 |
# File 'lib/cortex/snippets/webpage.rb', line 49 def nosnippet @contents[:nosnippet] end |
#product_data ⇒ Object
121 122 123 |
# File 'lib/cortex/snippets/webpage.rb', line 121 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 35 |
# 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 = unless Rails.env.production? || Rails.env.failover? robot_information end |
#seo_title ⇒ Object
13 14 15 |
# File 'lib/cortex/snippets/webpage.rb', line 13 def seo_title @contents[:seo_title] end |
#slider_widget_data ⇒ Object
85 86 87 |
# File 'lib/cortex/snippets/webpage.rb', line 85 def JSON.parse(@contents[:slider_widget_json] || 'null', quirks_mode: true) end |
#slider_widget_data_for(section_name) ⇒ Object
89 90 91 |
# File 'lib/cortex/snippets/webpage.rb', line 89 def (section_name) &.[](section_name) end |
#snippets ⇒ Object
129 130 131 |
# File 'lib/cortex/snippets/webpage.rb', line 129 def snippets @contents[:snippets] end |
#tables_widget_data ⇒ Object
61 62 63 |
# File 'lib/cortex/snippets/webpage.rb', line 61 def JSON.parse(@contents[:tables_widget_json] || 'null', quirks_mode: true) end |
#tables_widget_data_for(section_name) ⇒ Object
65 66 67 |
# File 'lib/cortex/snippets/webpage.rb', line 65 def (section_name) &.[](section_name) || [] end |