class MARC::Spec::Parsing::ClosedLcAlphaRange
Constants
- LCALPHA_RANGE_RE
- SIMPLE_CLASS_NAME
Public Instance Methods
to_s_inner(_prec)
click to toggle source
# File lib/marc/spec/parsing/closed_lc_alpha_range.rb, line 22 def to_s_inner(_prec) SIMPLE_CLASS_NAME end
try(source, context, _consume_all)
click to toggle source
# File lib/marc/spec/parsing/closed_lc_alpha_range.rb, line 11 def try(source, context, _consume_all) source_str = source.instance_variable_get(:@str) # TODO: something less hacky return context.err(self, source, 'Not a lower-case alphabetic range') unless (range_str = source_str.check(LCALPHA_RANGE_RE)) s, e = range_str.match(LCALPHA_RANGE_RE)[1, 2] return context.err(self, source, "#{s} !<= #{e}") unless s < e sv, _, ev = [s.size, 1, e.size].map { |l| source.consume(l) } # discard hyphen succ(from: sv, to: ev) end