Class: BEL::Extension::Format::JSONImplementation::EvidenceHandler

Inherits:
Oj::ScHandler
  • Object
show all
Defined in:
lib/bel/extensions/json/oj.rb

Instance Method Summary collapse

Constructor Details

#initialize(callable) ⇒ EvidenceHandler

Returns a new instance of EvidenceHandler.



31
32
33
# File 'lib/bel/extensions/json/oj.rb', line 31

def initialize(callable)
  @callable = callable
end

Instance Method Details

#array_append(array, value) ⇒ Object



53
54
55
56
# File 'lib/bel/extensions/json/oj.rb', line 53

def array_append(array, value)
  array << value
  @array = array
end

#array_endObject



58
59
60
# File 'lib/bel/extensions/json/oj.rb', line 58

def array_end()
  @callable.call @array
end

#array_startObject



48
49
50
51
# File 'lib/bel/extensions/json/oj.rb', line 48

def array_start
  @array = []
  @array
end

#error(message, line, column) ⇒ Object

Raises:

  • (Oj::ParseError)


62
63
64
65
# File 'lib/bel/extensions/json/oj.rb', line 62

def error(message, line, column)
  msg = "Parse error at line #{line}, column #{column}: #{message}"
  raise Oj::ParseError.new(msg)
end

#hash_endObject



39
40
41
# File 'lib/bel/extensions/json/oj.rb', line 39

def hash_end
  @callable.call @hash 
end

#hash_set(hash, key, value) ⇒ Object



43
44
45
46
# File 'lib/bel/extensions/json/oj.rb', line 43

def hash_set(hash, key, value)
  hash[key]  = value
  @hash = hash
end

#hash_startObject



35
36
37
# File 'lib/bel/extensions/json/oj.rb', line 35

def hash_start
  {}
end