Class: XMLScan::Input
- Inherits:
-
Object
- Object
- XMLScan::Input
- Defined in:
- lib/xmlscan/scanner.rb
Instance Attribute Summary collapse
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Class Method Summary collapse
Instance Method Summary collapse
- #gets ⇒ Object
-
#initialize(src) ⇒ Input
constructor
A new instance of Input.
- #lineno ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(src) ⇒ Input
Returns a new instance of Input.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/xmlscan/scanner.rb', line 46 def initialize(src) @src = src unless src.respond_to? :gets then if src.respond_to? :to_ary then @v = src.to_ary @n = -1 def self.gets ; @v.at(@n += 1) ; end def self.lineno ; @n + 1 ; end else @v = @src def self.gets ; s = @v ; @v = nil ; s ; end end end if src.respond_to? :lineno then def self.lineno ; @src.lineno ; end end if src.respond_to? :path then def self.path ; @src.path ; end end end |
Instance Attribute Details
#src ⇒ Object (readonly)
Returns the value of attribute src.
67 68 69 |
# File 'lib/xmlscan/scanner.rb', line 67 def src @src end |
Class Method Details
.unwrap(obj) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/xmlscan/scanner.rb', line 81 def self.unwrap(obj) if self === obj then obj.src else obj end end |
.wrap(src) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/xmlscan/scanner.rb', line 73 def self.wrap(src) unless src.respond_to? :gets and src.respond_to? :lineno and src.respond_to? :path then src = new(src) end src end |
Instance Method Details
#gets ⇒ Object
69 |
# File 'lib/xmlscan/scanner.rb', line 69 def gets ; @src.gets ; end |
#lineno ⇒ Object
70 |
# File 'lib/xmlscan/scanner.rb', line 70 def lineno ; 0 ; end |
#path ⇒ Object
71 |
# File 'lib/xmlscan/scanner.rb', line 71 def path ; '-' ; end |