class BLM::Document
Public Class Methods
new(source)
click to toggle source
# File lib/blm.rb, line 3 def initialize(source) @source = source end
Public Instance Methods
data()
click to toggle source
# File lib/blm.rb, line 30 def data return @data if defined?(@data) @data = [] get_contents(@source, "#DATA#", "#").split(header[:eor]).each do |line| entry = {} line.split(header[:eof]).each_with_index do |field, index| entry[definition[index].to_sym] = field.strip end @data << Row.new(entry) end return @data end
definition()
click to toggle source
# File lib/blm.rb, line 19 def definition return @definition if defined?(@definition) @definition = [] get_contents(@source, "#DEFINITION#", "#").split(header[:eor]).first.split(header[:eof]).each do |field| next if field.empty? @definition << field.downcase.strip end return @definition end
header()
click to toggle source
# File lib/blm.rb, line 7 def header return @header if defined?(@header) @header = {} get_contents(@source, "#HEADER#", "#").each_line do |line| next if line.empty? key, value = line.split(" : ") @header[key.downcase.to_sym] = value.gsub(/'/, "").strip end return @header end
Private Instance Methods
get_contents(string, start, finish)
click to toggle source
# File lib/blm.rb, line 45 def get_contents(string, start, finish) start = string.index(start) + start.size finish = string.index(finish, start) - finish.size string[start..finish].strip end