Class: AttributeStringFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/output/csv/attribute_string_factory.rb

Overview

singleton class to create a formatted String with the attribute names of of the submitted class

Class Method Summary collapse

Class Method Details

.get_attributes_to_person(person) ⇒ String

method to return the formatted String for the class of the given object

Parameters:

  • person (Person)

    a person or a child class of person

Returns:

  • (String)

    the formatted string with the attributes

Raises:

  • (TypeError)

    if no case of the given class of the object is found



11
12
13
14
15
16
17
18
# File 'lib/output/csv/attribute_string_factory.rb', line 11

def self.get_attributes_to_person(person)
  case person
    when Person::Student then return "Name:;Id:;Mat.-Nr.:"
    when Person::Person then return "Name:;Id:"
  else
    raise TypeError, "Invalid class type for factory: #{person.class}"
  end
end

.get_attributes_to_taskString

method to return the formatted String for the task attributes

Returns:

  • (String)

    the formatted string with the attributes of the task



22
23
24
# File 'lib/output/csv/attribute_string_factory.rb', line 22

def self.get_attributes_to_task
  "Task-Id;Description;Start;End"
end