Class: TableExtraction
- Inherits:
-
Array
- Object
- Array
- TableExtraction
- Defined in:
- lib/table_extraction.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
Instance Method Summary collapse
-
#initialize(url: '', id: '', klass: '') ⇒ TableExtraction
constructor
A new instance of TableExtraction.
Constructor Details
#initialize(url: '', id: '', klass: '') ⇒ TableExtraction
Returns a new instance of TableExtraction.
7 8 9 10 11 12 13 |
# File 'lib/table_extraction.rb', line 7 def initialize(url: '', id: '', klass: '') raise 'URLを入力してください' if url.empty? search_css = 'table' search_css << "##{id}" unless id.empty? search_css << ".#{klass}" unless klass.empty? @doc = Nokogiri::HTML(open(url)).css(search_css) end |
Instance Attribute Details
#doc ⇒ Object
Returns the value of attribute doc.
5 6 7 |
# File 'lib/table_extraction.rb', line 5 def doc @doc end |