Class: SCB::DB

Inherits:
Object
  • Object
show all
Defined in:
lib/scb/db.rb,
lib/scb/db/level.rb,
lib/scb/db/table.rb,
lib/scb/db/variable.rb

Defined Under Namespace

Classes: InvalidQuery, Level, Table, Variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api = nil) ⇒ DB

Returns a new instance of DB.



11
12
13
# File 'lib/scb/db.rb', line 11

def initialize(api = nil)
  @api = api || SCB.api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



9
10
11
# File 'lib/scb/db.rb', line 9

def api
  @api
end

Instance Method Details

#enObject



33
34
35
# File 'lib/scb/db.rb', line 33

def en
  language('en')
end

#level(name, text = nil, klass = Level) ⇒ Object



21
22
23
# File 'lib/scb/db.rb', line 21

def level(name, text = nil, klass = Level)
  klass.new(name, text, api)
end

#levels(klass = Level) ⇒ Object



15
16
17
18
19
# File 'lib/scb/db.rb', line 15

def levels(klass = Level)
  @levels ||= data.map do |l|
    klass.new(l["id"], l["text"], api)
  end
end

#svObject



37
38
39
# File 'lib/scb/db.rb', line 37

def sv
  language('sv')
end

#table(name, klass = Table) ⇒ Object



25
26
27
# File 'lib/scb/db.rb', line 25

def table(name, klass = Table)
  klass.new(name, api)
end

#uriObject



29
30
31
# File 'lib/scb/db.rb', line 29

def uri
  api.uri
end