Sha256: ec83eeb276e6cad93a9f3aac6731b0c76dcfdf4ada44609fe741b0f05a255ef3

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

module Hyogen
  #表から読み取ったレコード
  #表のラベルが属性名となり、表の値が属性の値となる。
  class Record < Hash
    def initialize
    end
    
    def set(label_names, value)
      target = self
      label_names.each_with_index do |name, i|
        if (i+1) == label_names.size
          target[name] = value
        else
          target[name] ||= {}
          target = target[name]
        end
      end
    end
  end
  
  class Label
    def initialize names, note
      @names = names  # Array of String
      @note = note  # (String, String)
    end
    attr_reader :names, :note
  end

  class Table
    def initialize(title)
      @title = title
      @labels = nil
      @records = nil
    end
    attr_reader :title
    attr_accessor :labels, :records
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyogen-0.0.2 lib/hyogen/table_elements.rb
hyogen-0.0.3 lib/hyogen/table_elements.rb