class SCB::DB::Level
Attributes
api[R]
name[R]
text[R]
Public Class Methods
new(name, text = nil, api = nil)
click to toggle source
# File lib/scb/db/level.rb, line 10 def initialize(name, text = nil, api = nil) @name = name @text = text @api = api || SCB.api end
Public Instance Methods
inspect()
click to toggle source
# File lib/scb/db/level.rb, line 24 def inspect name end
levels(klass = Level)
click to toggle source
# File lib/scb/db/level.rb, line 16 def levels(klass = Level) @levels ||= objects_for_type(klass, "l") end
tables(klass = Table)
click to toggle source
# File lib/scb/db/level.rb, line 20 def tables(klass = Table) @tables ||= objects_for_type(klass, "t") end
Private Instance Methods
data()
click to toggle source
# File lib/scb/db/level.rb, line 36 def data @data ||= api.get_and_parse(name) || [] end
objects_for_type(klass, type)
click to toggle source
# File lib/scb/db/level.rb, line 30 def objects_for_type(klass, type) data.map { |d| klass.new(d["id"], api) if d["type"] == type }.compact end