Class: Bookscan::Group

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGroup

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

#booksObject

Returns the value of attribute books.



7
8
9
# File 'lib/bookscan/group.rb', line 7

def books
  @books
end

#dateObject (readonly)

Returns the value of attribute date.



6
7
8
# File 'lib/bookscan/group.rb', line 6

def date
  @date
end

#hashObject (readonly)

Returns the value of attribute hash.



6
7
8
# File 'lib/bookscan/group.rb', line 6

def hash
  @hash
end

#numObject (readonly)

Returns the value of attribute num.



6
7
8
# File 'lib/bookscan/group.rb', line 6

def num
  @num
end

#paymentObject (readonly)

Returns the value of attribute payment.



6
7
8
# File 'lib/bookscan/group.rb', line 6

def payment
  @payment
end

#priceObject (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

Returns:



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_aObject



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

#urlObject



24
25
26
# File 'lib/bookscan/group.rb', line 24

def url
  "/bookdetail.php?hash=" + @hash
end