Class: Geckoboard::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/geckoboard/field_types.rb

Direct Known Subclasses

DateField, DateTimeField, OptionalField, StringField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name: nil) ⇒ Field

Returns a new instance of Field.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'lib/geckoboard/field_types.rb', line 5

def initialize(id, name: nil)
  raise ArgumentError, "`id:' is a required argument" if id.nil?

  @id   = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/geckoboard/field_types.rb', line 3

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/geckoboard/field_types.rb', line 3

def name
  @name
end

Instance Method Details

#to_hashObject



12
13
14
# File 'lib/geckoboard/field_types.rb', line 12

def to_hash
  { name: name }
end