Class: Iev::SupersessionParser

Inherits:
Object
  • Object
show all
Includes:
Cli::Ui
Defined in:
lib/iev/supersession_parser.rb

Overview

Parses information from the spreadsheet’s REPLACES column.

Examples:

SupersessionParser.new(cell_data_string).supersessions

Constant Summary collapse

IEV_SUPERSESSION_RX =

Regular expression which describes IEV relation, for example 881-01-23:1983-01 or 845-03-55:1987.

/
  \A
  (?:IEV\s+)? # some are prefixed with IEV, it is unnecessary though
  (?<ref>\d{3}-\d{2}-\d{2})
  \s* # some have whitespaces around the separator
  : # separator
  \s* # some have whitespaces around the separator
  (?<version>[-0-9]+)
  \Z
/x

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cli::Ui

debug, info, progress, set_ui_tag, warn

Constructor Details

#initialize(source_str) ⇒ SupersessionParser

Returns a new instance of SupersessionParser.



31
32
33
34
35
# File 'lib/iev/supersession_parser.rb', line 31

def initialize(source_str)
  @raw_str = source_str.dup.freeze
  @src_str = raw_str.sanitize.freeze
  @supersessions = parse
end

Instance Attribute Details

#raw_strObject (readonly)

Returns the value of attribute raw_str.



16
17
18
# File 'lib/iev/supersession_parser.rb', line 16

def raw_str
  @raw_str
end

#src_strObject (readonly)

Returns the value of attribute src_str.



16
17
18
# File 'lib/iev/supersession_parser.rb', line 16

def src_str
  @src_str
end

#supersessionsObject (readonly)

Returns the value of attribute supersessions.



16
17
18
# File 'lib/iev/supersession_parser.rb', line 16

def supersessions
  @supersessions
end