Class: CDB::Issue
Constant Summary collapse
- FORM_SEARCHTYPE =
'IssueName'
- WEB_PATH =
'issue.php'
Instance Attribute Summary collapse
-
#cdb_id ⇒ Object
Returns the value of attribute cdb_id.
-
#cover_date ⇒ Object
Returns the value of attribute cover_date.
-
#name ⇒ Object
Returns the value of attribute name.
-
#num ⇒ Object
Returns the value of attribute num.
-
#series ⇒ Object
Returns the value of attribute series.
-
#story_arc ⇒ Object
Returns the value of attribute story_arc.
Class Method Summary collapse
Methods inherited from Struct
#as_json, #initialize, #to_json
Constructor Details
This class inherits a constructor from CDB::Struct
Instance Attribute Details
#cdb_id ⇒ Object
Returns the value of attribute cdb_id
2 3 4 |
# File 'lib/cdb/issue.rb', line 2 def cdb_id @cdb_id end |
#cover_date ⇒ Object
Returns the value of attribute cover_date
2 3 4 |
# File 'lib/cdb/issue.rb', line 2 def cover_date @cover_date end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/cdb/issue.rb', line 2 def name @name end |
#num ⇒ Object
Returns the value of attribute num
2 3 4 |
# File 'lib/cdb/issue.rb', line 2 def num @num end |
#series ⇒ Object
Returns the value of attribute series
2 3 4 |
# File 'lib/cdb/issue.rb', line 2 def series @series end |
#story_arc ⇒ Object
Returns the value of attribute story_arc
2 3 4 |
# File 'lib/cdb/issue.rb', line 2 def story_arc @story_arc end |
Class Method Details
.from_tr(node, series) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cdb/issue.rb', line 25 def from_tr(node, series) tds = node.css('td') link = tds[0].css("a[href^=\"#{WEB_PATH}\"]").first new(:cdb_id => link['href'].split('=').last.strip.to_i, :series => series, :num => link.text.strip, :name => tds[2].text.strip, :story_arc => tds[4].text.strip, :cover_date => tds[6].text.strip) end |
.parse_results(node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cdb/issue.rb', line 13 def parse_results(node) node.css("a[href^=\"#{WEB_PATH}\"]").map do |link| id = link.attr('href').split('=').last.to_i text = link.child.text.strip match = text.match(/^(.* \(\d{4}\)) (.*)$/) series = match[1] num = match[2].gsub(/^#/, '') name = link.next_sibling.text.strip.gsub(/^-\s*"|"$/, '').strip new(:cdb_id => id, :series => series, :num => num, :name => name) end.sort_by(&:cdb_id) end |
.search(query) ⇒ Object
8 9 10 11 |
# File 'lib/cdb/issue.rb', line 8 def search(query) results = CDB.search(query, FORM_SEARCHTYPE) results[:issues] end |