Class: HTTPong::Scheme
- Inherits:
-
Object
- Object
- HTTPong::Scheme
- Defined in:
- lib/httpong/scheme.rb
Instance Attribute Summary collapse
-
#cson_path ⇒ Object
readonly
Returns the value of attribute cson_path.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
(also: #json_path)
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Scheme
constructor
A new instance of Scheme.
- #name ⇒ Object
- #reload ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(path) ⇒ Scheme
Returns a new instance of Scheme.
8 9 10 11 12 |
# File 'lib/httpong/scheme.rb', line 8 def initialize(path) @path = path reload HTTPong.schemes << self end |
Instance Attribute Details
#cson_path ⇒ Object (readonly)
Returns the value of attribute cson_path.
5 6 7 |
# File 'lib/httpong/scheme.rb', line 5 def cson_path @cson_path end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/httpong/scheme.rb', line 3 def data @data end |
#path ⇒ Object (readonly) Also known as: json_path
Returns the value of attribute path.
4 5 6 |
# File 'lib/httpong/scheme.rb', line 4 def path @path end |
Instance Method Details
#name ⇒ Object
14 15 16 |
# File 'lib/httpong/scheme.rb', line 14 def name @data['name'] end |
#reload ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/httpong/scheme.rb', line 18 def reload if path.end_with? 'cson' json_path = "#{@path.chomp('cson')}json" `cson2json #{@path} > #{json_path}` @cson_path = @path @json_path = json_path else @json_path = @path end file = File.read(@json_path) @data = JSON.parse(file) end |
#to_json ⇒ Object
31 32 33 |
# File 'lib/httpong/scheme.rb', line 31 def to_json JSON.generate(@data) end |