module Bmg::Reader

Attributes

type[RW]

Private Instance Methods

infer_type(base) click to toggle source
# File lib/bmg/reader/text_file.rb, line 31
def infer_type(base)
  return base unless base == Bmg::Type::ANY
  attr_list = if rx = options[:parse]
    [:line] + rx.names.map(&:to_sym)
  else
    [:line, :text]
  end
  base
    .with_attrlist(attr_list)
    .with_keys([[:line]])
end
parse(text) click to toggle source
# File lib/bmg/reader/text_file.rb, line 47
def parse(text)
  return { text: text } unless rx = options[:parse]
  if match = rx.match(text)
    TupleAlgebra.symbolize_keys(match.named_captures)
  end
end
strip?() click to toggle source
# File lib/bmg/reader/text_file.rb, line 43
def strip?
  options[:strip]
end