Class: Badger::Fields

Inherits:
Object
  • Object
show all
Defined in:
lib/badger/fields.rb

Defined Under Namespace

Classes: FormatError

Constant Summary collapse

DEFAULT_ROLE =
'Attendee'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, template, default_role = nil) ⇒ Fields

Returns a new instance of Fields.



12
13
14
15
16
17
18
# File 'lib/badger/fields.rb', line 12

def initialize(filename, template, default_role=nil)
  @filename = filename
  @data = YAML.load(File.read(filename))
  @template = template
  @default_role = default_role || DEFAULT_ROLE
  check_fields
end

Instance Attribute Details

#filename ⇒ Object (readonly)

Returns the value of attribute filename.



11
12
13
# File 'lib/badger/fields.rb', line 11

def filename
  @filename
end

Instance Method Details

#in_pages_of(number) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/badger/fields.rb', line 20

def in_pages_of(number)
  fdf_template = ERB.new(File.read(File.join(File.dirname(__FILE__), '../../data/fields.rfdf')), nil, '>')
  page_number = 0
  @data.in_groups_of(number) do |p|
    people = p
    page_number += 1
    yield(fdf_template.result(binding), page_number)
  end
end