Class: Cortex::Snippets::Webpage

Inherits:
Object
  • Object
show all
Defined in:
lib/cortex/snippets/webpage.rb

Instance Method Summary collapse

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_dataObject



70
71
72
# File 'lib/cortex/snippets/webpage.rb', line 70

def accordion_group_widget_data
  JSON.parse(@webpage[:accordion_group_widget_json] || 'null', quirks_mode: true)
end

#accordion_group_widget_data_for(section_name) ⇒ Object



74
75
76
# File 'lib/cortex/snippets/webpage.rb', line 74

def accordion_group_widget_data_for(section_name)
  accordion_group_widget_data&.[](section_name) || []
end

#charts_widget_dataObject



78
79
80
# File 'lib/cortex/snippets/webpage.rb', line 78

def charts_widget_data
  JSON.parse(@webpage[:charts_widget_json] || 'null', quirks_mode: true)
end

#charts_widget_data_for(section_name) ⇒ Object



82
83
84
# File 'lib/cortex/snippets/webpage.rb', line 82

def charts_widget_data_for(section_name)
  charts_widget_data&.[](section_name) || {}
end

#dynamic_yieldObject



55
56
57
58
59
60
# File 'lib/cortex/snippets/webpage.rb', line 55

def dynamic_yield
  {
    sku: @webpage[:dynamic_yield_sku],
    category: @webpage[:dynamic_yield_category]
  }
end

#noarchiveObject



47
48
49
# File 'lib/cortex/snippets/webpage.rb', line 47

def noarchive
  @webpage[:noarchive]
end

#nofollowObject



35
36
37
# File 'lib/cortex/snippets/webpage.rb', line 35

def nofollow
  @webpage[:nofollow]
end

#noimageindexObject



51
52
53
# File 'lib/cortex/snippets/webpage.rb', line 51

def noimageindex
  @webpage[:noimageindex]
end

#noindexObject



31
32
33
# File 'lib/cortex/snippets/webpage.rb', line 31

def noindex
  @webpage[:noindex]
end

#noodpObject



39
40
41
# File 'lib/cortex/snippets/webpage.rb', line 39

def noodp
  @webpage[:noodp]
end

#nosnippetObject



43
44
45
# File 'lib/cortex/snippets/webpage.rb', line 43

def nosnippet
  @webpage[:nosnippet]
end

#seo_descriptionObject



12
13
14
# File 'lib/cortex/snippets/webpage.rb', line 12

def seo_description
  @webpage[:seo_description]
end

#seo_keywordsObject



16
17
18
# File 'lib/cortex/snippets/webpage.rb', line 16

def seo_keywords
  @webpage[:seo_keyword_list]
end

#seo_robotsObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/cortex/snippets/webpage.rb', line 20

def seo_robots
  robot_information = []
  index_options = [:noindex, :nofollow, :noodp, :nosnippet, :noarchive, :noimageindex]

  index_options.each do |index_option|
    robot_information << index_option if @webpage[index_option]
  end

  robot_information
end

#seo_titleObject



8
9
10
# File 'lib/cortex/snippets/webpage.rb', line 8

def seo_title
  @webpage[:seo_title]
end

#snippetsObject



86
87
88
# File 'lib/cortex/snippets/webpage.rb', line 86

def snippets
  @webpage[:snippets]
end

#tables_widget_dataObject



62
63
64
# File 'lib/cortex/snippets/webpage.rb', line 62

def tables_widget_data
  JSON.parse(@webpage[:tables_widget_json] || 'null', quirks_mode: true)
end

#tables_widget_data_for(section_name) ⇒ Object



66
67
68
# File 'lib/cortex/snippets/webpage.rb', line 66

def tables_widget_data_for(section_name)
  tables_widget_data&.[](section_name) || []
end