Class: Mushikago::Hanamgri::Field

Inherits:
Struct
  • Object
show all
Defined in:
lib/mushikago/hanamgri/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#knowledge_nameObject

Returns the value of attribute knowledge_name

Returns:

  • (Object)

    the current value of knowledge_name



5
6
7
# File 'lib/mushikago/hanamgri/field.rb', line 5

def knowledge_name
  @knowledge_name
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/mushikago/hanamgri/field.rb', line 5

def name
  @name
end

#requiredObject

Returns the value of attribute required

Returns:

  • (Object)

    the current value of required



5
6
7
# File 'lib/mushikago/hanamgri/field.rb', line 5

def required
  @required
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'lib/mushikago/hanamgri/field.rb', line 5

def type
  @type
end

Instance Method Details

#required?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/mushikago/hanamgri/field.rb', line 10

def required?
  !!required
end

#to_json(*args) ⇒ Object



14
15
16
# File 'lib/mushikago/hanamgri/field.rb', line 14

def to_json *args
  {:name => name.to_s, :required => required?, :type => type, :knowledge_name => knowledge_name}.to_json(args)
end

#validate!Object



6
7
8
# File 'lib/mushikago/hanamgri/field.rb', line 6

def validate!
  raise "Invalid Type Value [#{type}]" unless [:string, :number].include?(type)
end