Class: Elpong::Scheme

Inherits:
Object
  • Object
show all
Defined in:
lib/elpong/scheme.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Scheme



6
7
8
9
10
# File 'lib/elpong/scheme.rb', line 6

def initialize(path)
  @path = path
  reload
  Elpong.schemes << self
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/elpong/scheme.rb', line 3

def data
  @data
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/elpong/scheme.rb', line 4

def path
  @path
end

Instance Method Details

#nameObject



12
13
14
# File 'lib/elpong/scheme.rb', line 12

def name
  @data['name']
end

#reloadObject



16
17
18
19
# File 'lib/elpong/scheme.rb', line 16

def reload
  file = File.read(@path)
  @data = JSON.parse(file)
end

#to_jsonObject



21
22
23
# File 'lib/elpong/scheme.rb', line 21

def to_json
  JSON.generate(@data)
end