Class: Fluent::Json::Schema::Terms::Str

Inherits:
Field
  • Object
show all
Defined in:
lib/fluent/json/schema/terms/str.rb

Direct Known Subclasses

Date

Instance Attribute Summary collapse

Attributes inherited from Field

#constraints, #default, #enum, #name, #required, #version

Instance Method Summary collapse

Methods inherited from Field

#mandate, #optionalise

Constructor Details

#initialize(name, options = {}) ⇒ Str

Returns a new instance of Str.



7
8
9
# File 'lib/fluent/json/schema/terms/str.rb', line 7

def initialize(name, options={})
  super(name, options)
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/fluent/json/schema/terms/str.rb', line 5

def format
  @format
end

#max_lengthObject (readonly)

Returns the value of attribute max_length.



5
6
7
# File 'lib/fluent/json/schema/terms/str.rb', line 5

def max_length
  @max_length
end

#min_lengthObject (readonly)

Returns the value of attribute min_length.



5
6
7
# File 'lib/fluent/json/schema/terms/str.rb', line 5

def min_length
  @min_length
end

#patternObject (readonly)

Returns the value of attribute pattern.



5
6
7
# File 'lib/fluent/json/schema/terms/str.rb', line 5

def pattern
  @pattern
end

Instance Method Details

#as_jsonObject



32
33
34
35
36
# File 'lib/fluent/json/schema/terms/str.rb', line 32

def as_json
  super({ type: :string }).merge!(
    self.as_json_fragment(:min_length, :max_length, :format, :pattern)
  )
end

#datetimeObject



20
21
22
# File 'lib/fluent/json/schema/terms/str.rb', line 20

def datetime
  @format = :'date-time'
end

#emailObject



24
25
26
# File 'lib/fluent/json/schema/terms/str.rb', line 24

def email
  @format = :email
end

#set(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/fluent/json/schema/terms/str.rb', line 11

def set(options={})
  super(options)
  @min_length ||= options[:min]
  @max_length ||= options[:max]
  @format ||= options[:fmt]
  @pattern ||= options[:pattern]
  return self
end

#uriObject



28
29
30
# File 'lib/fluent/json/schema/terms/str.rb', line 28

def uri
  @format = :uri
end