Class: Cortex::Snippets::Webpage
- Inherits:
-
Object
- Object
- Cortex::Snippets::Webpage
- Defined in:
- lib/cortex/snippets/webpage.rb
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
- #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.
4 5 6 |
# File 'lib/cortex/snippets/webpage.rb', line 4 def initialize(cortex_client, url) @webpage = cortex_client.webpages.get_feed(url).contents end |
Instance Method Details
#accordion_group_widget_data ⇒ Object
79 80 81 |
# File 'lib/cortex/snippets/webpage.rb', line 79 def JSON.parse(@webpage[:accordion_group_widget_json] || 'null', quirks_mode: true) end |
#accordion_group_widget_data_for(section_name) ⇒ Object
83 84 85 |
# File 'lib/cortex/snippets/webpage.rb', line 83 def (section_name) &.[](section_name) || [] end |
#buy_box_widget_data ⇒ Object
91 92 93 |
# File 'lib/cortex/snippets/webpage.rb', line 91 def JSON.parse(@webpage[:buy_box_widget_json] || 'null', quirks_mode: true) end |
#carousels_widget_data ⇒ Object
63 64 65 |
# File 'lib/cortex/snippets/webpage.rb', line 63 def JSON.parse(@webpage[:carousels_widget_json] || 'null', quirks_mode: true) end |
#carousels_widget_data_for(section_name) ⇒ Object
67 68 69 |
# File 'lib/cortex/snippets/webpage.rb', line 67 def (section_name) &.[](section_name) end |
#charts_widget_data ⇒ Object
87 88 89 |
# File 'lib/cortex/snippets/webpage.rb', line 87 def JSON.parse(@webpage[:charts_widget_json] || 'null', quirks_mode: true) end |
#charts_widget_data_for(section_name) ⇒ Object
95 96 97 |
# File 'lib/cortex/snippets/webpage.rb', line 95 def (section_name) &.[](section_name) || {} end |
#galleries_widget_data ⇒ Object
71 72 73 |
# File 'lib/cortex/snippets/webpage.rb', line 71 def JSON.parse(@webpage[:galleries_widget_json] || 'null', quirks_mode: true) end |
#galleries_widget_data_for(section_name) ⇒ Object
75 76 77 |
# File 'lib/cortex/snippets/webpage.rb', line 75 def (section_name) &.[](section_name) end |
#noarchive ⇒ Object
47 48 49 |
# File 'lib/cortex/snippets/webpage.rb', line 47 def noarchive @webpage[:noarchive] end |
#nofollow ⇒ Object
35 36 37 |
# File 'lib/cortex/snippets/webpage.rb', line 35 def nofollow @webpage[:nofollow] end |
#noimageindex ⇒ Object
51 52 53 |
# File 'lib/cortex/snippets/webpage.rb', line 51 def noimageindex @webpage[:noimageindex] end |
#noindex ⇒ Object
31 32 33 |
# File 'lib/cortex/snippets/webpage.rb', line 31 def noindex @webpage[:noindex] end |
#noodp ⇒ Object
39 40 41 |
# File 'lib/cortex/snippets/webpage.rb', line 39 def noodp @webpage[:noodp] end |
#nosnippet ⇒ Object
43 44 45 |
# File 'lib/cortex/snippets/webpage.rb', line 43 def nosnippet @webpage[:nosnippet] end |
#product_data ⇒ Object
99 100 101 |
# File 'lib/cortex/snippets/webpage.rb', line 99 def product_data JSON.parse(@webpage[:product_data_json] || 'null', quirks_mode: true) end |
#seo_description ⇒ Object
12 13 14 |
# File 'lib/cortex/snippets/webpage.rb', line 12 def seo_description @webpage[:seo_description] end |
#seo_keywords ⇒ Object
16 17 18 |
# File 'lib/cortex/snippets/webpage.rb', line 16 def seo_keywords @webpage[:seo_keyword_list] end |
#seo_robots ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cortex/snippets/webpage.rb', line 20 def seo_robots robot_information = [] = [:noindex, :nofollow, :noodp, :nosnippet, :noarchive, :noimageindex] .each do |index_option| robot_information << index_option if @webpage[index_option] end robot_information end |
#seo_title ⇒ Object
8 9 10 |
# File 'lib/cortex/snippets/webpage.rb', line 8 def seo_title @webpage[:seo_title] end |
#snippets ⇒ Object
103 104 105 |
# File 'lib/cortex/snippets/webpage.rb', line 103 def snippets @webpage[:snippets] end |
#tables_widget_data ⇒ Object
55 56 57 |
# File 'lib/cortex/snippets/webpage.rb', line 55 def JSON.parse(@webpage[:tables_widget_json] || 'null', quirks_mode: true) end |
#tables_widget_data_for(section_name) ⇒ Object
59 60 61 |
# File 'lib/cortex/snippets/webpage.rb', line 59 def (section_name) &.[](section_name) || [] end |