Class: RelatonEtsi::PubId::Parser
- Inherits:
-
Object
- Object
- RelatonEtsi::PubId::Parser
- Defined in:
- lib/relaton_etsi/pubid.rb
Instance Method Summary collapse
-
#initialize(id) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(id) ⇒ Parser
Returns a new instance of Parser.
4 5 6 |
# File 'lib/relaton_etsi/pubid.rb', line 4 def initialize(id) @strscan = StringScanner.new id end |
Instance Method Details
#parse ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/relaton_etsi/pubid.rb', line 8 def parse @strscan.scan(/^ETSI\s+/) type = @strscan.scan(/\S+/) @strscan.scan(/\s+/) docnumber = @strscan.scan_until(/(?=\s(V\d+\.\d+\.\d+)|ed\.\d+)/) version = @strscan.scan(/\d+\.\d+\.\d+/) if @strscan.scan(/\sV(?=\d+\.\d+\.\d+)/) edition = @strscan.scan(/\d+/) if @strscan.scan(/\sed\.(?=\d+)/) date = @strscan.scan(/\d{4}-\d{2}/) if @strscan.scan(/\s\(/) { type: type, docnumber: docnumber, version: version, edition: edition, date: date } end |