class Factbook::Category

Attributes

title[R]

Public Class Methods

new( title ) click to toggle source
# File lib/factbook-fields/category.rb, line 10
def initialize( title )
  @title  = title
  @fields = {}
end

Public Instance Methods

<<( field )
Alias for: add
[](key) click to toggle source
# File lib/factbook-fields/category.rb, line 21
def [](key)  ### convenience shortcut
  @fields[ key ]
end
add( field ) click to toggle source
# File lib/factbook-fields/category.rb, line 15
def add( field )
  @fields[ field.title ] = field
end
Also aliased as: <<
data() click to toggle source
# File lib/factbook-fields/category.rb, line 29
def data   ## convert to hash
  ## todo/fix: how to know when to rebuild?
  ##   for now @data MUST be reset to nil manually
  data = {}
  @fields.each do |_,field|
    data[ field.title ] = field.data
  end
  data
end
size() click to toggle source
# File lib/factbook-fields/category.rb, line 25
def size()   @fields.size; end