Class: Field

Inherits:
CheckValues show all
Defined in:
lib/chino_ruby.rb

Overview

Class which defines the fields for the creation of a Schema or a UserSchema

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CheckValues

#check_boolean, #check_int, #check_json, #check_string

Constructor Details

#initialize(type, name, indexed) ⇒ Field

  • type: type of the field in the Schema/UserSchema. Ex: ‘string’

  • name: name of the field in the Schema/UserSchema

  • indexed: if true, the field will be indexed on the server. That means it can be used to make a search request



89
90
91
92
93
94
95
96
# File 'lib/chino_ruby.rb', line 89

def initialize(type, name, indexed)
    check_string(type)
    check_string(name)
    check_boolean(indexed)
    self.type = type
    self.name = name
    self.indexed = indexed
end

Instance Attribute Details

#indexedObject

Returns the value of attribute indexed.



84
85
86
# File 'lib/chino_ruby.rb', line 84

def indexed
  @indexed
end

#nameObject

Returns the value of attribute name.



84
85
86
# File 'lib/chino_ruby.rb', line 84

def name
  @name
end

#typeObject

Returns the value of attribute type.



84
85
86
# File 'lib/chino_ruby.rb', line 84

def type
  @type
end

Instance Method Details

#to_jsonObject

Returns the values as a json



99
100
101
# File 'lib/chino_ruby.rb', line 99

def to_json
    return {"type": type, "name": name, "indexed": indexed}.to_json
end