Class: RBook::Onix::Listener
- Inherits:
-
Object
- Object
- RBook::Onix::Listener
show all
- Defined in:
- lib/rbook/onix/stream_reader.rb
Overview
a utility class for the ONIX Stream Reader. See RBook::ONIX::StreamReader for basic usage instructions.
Instance Method Summary
collapse
Constructor Details
#initialize(queue) ⇒ Listener
Returns a new instance of Listener.
12
13
14
15
|
# File 'lib/rbook/onix/stream_reader.rb', line 12
def initialize(queue)
@queue = queue
@in_product = false
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
77
78
79
|
# File 'lib/rbook/onix/stream_reader.rb', line 77
def method_missing(*args)
end
|
Instance Method Details
#doctype(name, pub_sys, long_name, uri) ⇒ Object
17
18
19
|
# File 'lib/rbook/onix/stream_reader.rb', line 17
def doctype(name, pub_sys, long_name, uri)
end
|
#end_document ⇒ Object
70
71
72
73
74
75
|
# File 'lib/rbook/onix/stream_reader.rb', line 70
def end_document
@queue.push(nil)
end
|
#instruction(name, instruction) ⇒ Object
21
22
23
|
# File 'lib/rbook/onix/stream_reader.rb', line 21
def instruction(name, instruction)
end
|
#tag_end(name) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/rbook/onix/stream_reader.rb', line 41
def tag_end(name)
case name
when "ONIXMessage"
@queue.push(nil)
when "Product"
@product_fragment << "</Product>"
begin
product = RBook::Onix::Product.load_from_string(@product_fragment)
@queue.push(product) unless product.nil?
rescue Exception => e
@queue.push(e)
end
@in_product = false
else
@product_fragment << "</#{name}>" if @in_product
end
end
|
#tag_start(name, attrs) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rbook/onix/stream_reader.rb', line 25
def tag_start(name, attrs)
case name
when "Product"
@in_product = true
@product_fragment = "<Product>"
else
@product_fragment << "<#{name}>" if @in_product
end
end
|
#text(text) ⇒ Object
37
38
39
|
# File 'lib/rbook/onix/stream_reader.rb', line 37
def text(text)
@product_fragment << text.to_xs if @in_product
end
|
#xmldecl(version, encoding, standalone) ⇒ Object
66
67
68
|
# File 'lib/rbook/onix/stream_reader.rb', line 66
def xmldecl(version, encoding, standalone)
end
|