Class: SwedbankPay::SidebarPageTitle

Inherits:
Object
  • Object
show all
Defined in:
lib/sidebar_page_title.rb

Overview

Represents the title of a SidebarPage

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mainObject (readonly)

Returns the value of attribute main.



9
10
11
# File 'lib/sidebar_page_title.rb', line 9

def main
  @main
end

#sectionObject (readonly)

Returns the value of attribute section.



9
10
11
# File 'lib/sidebar_page_title.rb', line 9

def section
  @section
end

Class Method Details

.parse(jekyll_page, sidebar_page) ⇒ Object

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sidebar_page_title.rb', line 11

def self.parse(jekyll_page, sidebar_page)
  raise ArgumentError, 'jekyll_page cannot be nil' if jekyll_page.nil?
  raise ArgumentError, 'jekyll_page must be a Jekyll::Page' unless jekyll_page.is_a? Jekyll::Page
  raise ArgumentError, 'sidebar_page cannot be nil' if sidebar_page.nil?
  raise ArgumentError, 'sidebar_page must be a SidebarPage' unless sidebar_page.is_a? SidebarPage

  title = jekyll_page['title']
  section = jekyll_page['section']

  return nil if title.nil? && section.nil?

  SidebarPageTitle.new(title, section, sidebar_page)
end

Instance Method Details

#<=>(other) ⇒ Object



40
41
42
43
44
# File 'lib/sidebar_page_title.rb', line 40

def <=>(other)
  return -1 if other.nil?

  @title <=> other.to_s
end

#inspectObject



36
37
38
# File 'lib/sidebar_page_title.rb', line 36

def inspect
  @title
end

#leadObject



25
26
27
28
29
30
# File 'lib/sidebar_page_title.rb', line 25

def lead
  section = find_section(@page)
  return section unless section.nil?

  @lead
end

#to_sObject



32
33
34
# File 'lib/sidebar_page_title.rb', line 32

def to_s
  @title
end