Class: Jsapi::JSON::String

Inherits:
Value
  • Object
show all
Defined in:
lib/jsapi/json/string.rb

Overview

Represents a JSON string.

Instance Attribute Summary collapse

Attributes inherited from Value

#schema

Instance Method Summary collapse

Methods inherited from Value

#inspect, #null?, #validate

Constructor Details

#initialize(value, schema) ⇒ String

Returns a new instance of String.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jsapi/json/string.rb', line 9

def initialize(value, schema)
  super(schema)
  @value = schema.convert(
    case schema.format
    when 'date'
      value.to_date
    when 'date-time'
      value.to_datetime
    else
      value.to_s
    end
  )
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



7
8
9
# File 'lib/jsapi/json/string.rb', line 7

def value
  @value
end

Instance Method Details

#empty?Boolean

See Value#empty?.

Returns:



24
25
26
# File 'lib/jsapi/json/string.rb', line 24

def empty?
  value.blank?
end