Class: Fossyl::Parser
- Inherits:
-
Object
- Object
- Fossyl::Parser
- Defined in:
- lib/fossyl/parser.rb
Instance Attribute Summary collapse
-
#scanner ⇒ Object
readonly
Returns the value of attribute scanner.
Instance Method Summary collapse
-
#initialize(string) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(string) ⇒ Parser
Returns a new instance of Parser.
6 7 8 |
# File 'lib/fossyl/parser.rb', line 6 def initialize(string) @scanner = StringScanner.new(string) end |
Instance Attribute Details
#scanner ⇒ Object (readonly)
Returns the value of attribute scanner.
4 5 6 |
# File 'lib/fossyl/parser.rb', line 4 def scanner @scanner end |
Instance Method Details
#parse ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/fossyl/parser.rb', line 10 def parse return parse_string if scanner.scan(/\d+/) return parse_integer if scanner.scan(/i/) return parse_list if scanner.scan(/l/) return parse_dictionary if scanner.scan(/d/) raise Fossyl::InvalidBencoding end |