Class: Bookscan::Group
- Inherits:
-
Object
- Object
- Bookscan::Group
- Defined in:
- lib/bookscan/group.rb
Instance Attribute Summary collapse
-
#books ⇒ Object
Returns the value of attribute books.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#num ⇒ Object
readonly
Returns the value of attribute num.
-
#payment ⇒ Object
readonly
Returns the value of attribute payment.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #import(tr) ⇒ Object
-
#initialize ⇒ Group
constructor
A new instance of Group.
- #to_a ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ Group
Returns a new instance of Group.
9 10 11 |
# File 'lib/bookscan/group.rb', line 9 def initialize @books = Books.new end |
Instance Attribute Details
#books ⇒ Object
Returns the value of attribute books.
7 8 9 |
# File 'lib/bookscan/group.rb', line 7 def books @books end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/bookscan/group.rb', line 6 def date @date end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
6 7 8 |
# File 'lib/bookscan/group.rb', line 6 def hash @hash end |
#num ⇒ Object (readonly)
Returns the value of attribute num.
6 7 8 |
# File 'lib/bookscan/group.rb', line 6 def num @num end |
#payment ⇒ Object (readonly)
Returns the value of attribute payment.
6 7 8 |
# File 'lib/bookscan/group.rb', line 6 def payment @payment end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
6 7 8 |
# File 'lib/bookscan/group.rb', line 6 def price @price end |
Instance Method Details
#completed? ⇒ Boolean
48 49 50 |
# File 'lib/bookscan/group.rb', line 48 def completed? @is_completed end |
#import(tr) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bookscan/group.rb', line 28 def import(tr) a = Array.new tr.search("td").each do |td| a << td.text.to_s end if /hash=(.+)/ =~ tr.at("a/@href") @hash = $1 end # puts url @date = a[0] @num = a[1] @price = a[2] @payment = a[3] @is_completed = true if a[6] == "未完了" @is_completed = false end end |
#to_a ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bookscan/group.rb', line 13 def to_a if completed? @status = "完了" else @status = "未完了" end [@hash,@date,@num,@price,@payment,@status].collect { |i| i.force_encoding("utf-8") if i.respond_to?(:force_encoding) } end |
#url ⇒ Object
24 25 26 |
# File 'lib/bookscan/group.rb', line 24 def url "/bookdetail.php?hash=" + @hash end |