Class: Tenet::IndexPage

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

Constant Summary collapse

@@url =
""
@@row =
""
@@attributes =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIndexPage

Returns a new instance of IndexPage.



33
34
35
36
37
38
39
# File 'lib/tenet/index_page.rb', line 33

def initialize
  @collection = []

  Page.new(@@url).document.css(@@row).each do |row_document|
    @collection << Row.new(row_document.to_html, @@attributes).to_h
  end
end

Class Method Details

.attribute(name, css:, type: :string) ⇒ Object

Parameters:

  • name (Symbol)
  • css (String)
  • type (Symbol) (defaults to: :string)


28
29
30
# File 'lib/tenet/index_page.rb', line 28

def attribute(name, css:, type: :string)
  @@attributes << Attribute.new(name, css: css, type: type)
end

.row(css) ⇒ Object

Parameters:

  • css (String)


19
20
21
# File 'lib/tenet/index_page.rb', line 19

def row(css)
  @@row = css
end

.url(url) ⇒ Object

Parameters:

  • url (String)


12
13
14
# File 'lib/tenet/index_page.rb', line 12

def url(url)
  @@url = url
end

Instance Method Details

#to_aArray<Hash>

Returns:

  • (Array<Hash>)


44
45
46
# File 'lib/tenet/index_page.rb', line 44

def to_a
  @collection
end