class Bismas::Schema
Constants
- CATEGORY_RE
- FIELD_RE
Attributes
category_length[RW]
name[RW]
title[RW]
Public Class Methods
new()
click to toggle source
# File lib/bismas/schema.rb 55 def initialize 56 @title, @name, @category_length, @categories = nil, nil, nil, {} 57 end
parse(*args)
click to toggle source
# File lib/bismas/schema.rb 44 def parse(*args) 45 new.parse(*args) 46 end
parse_file(file, options = {})
click to toggle source
# File lib/bismas/schema.rb 48 def parse_file(file, options = {}) 49 Bismas.amend_encoding(options) 50 File.open(file, 'rb', options, &method(:parse)) 51 end
Public Instance Methods
parse(io)
click to toggle source
# File lib/bismas/schema.rb 65 def parse(io) 66 category_re = nil 67 68 io.each { |line| 69 case line 70 when category_re 71 self[$1.strip] = $2.strip 72 when FIELD_RE 73 category_re = CATEGORY_RE[ 74 self.category_length = $1.to_i] 75 when String 76 title ? name ? nil : 77 self.name = line.strip : 78 self.title = line.strip 79 end 80 } 81 82 self 83 end