Class: PodPrebuild::JSONFile
- Inherits:
-
Object
- Object
- PodPrebuild::JSONFile
- Defined in:
- lib/cocoapods-binary-ht/helper/json.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(path) ⇒ JSONFile
constructor
A new instance of JSONFile.
- #save! ⇒ Object
Constructor Details
#initialize(path) ⇒ JSONFile
Returns a new instance of JSONFile.
8 9 10 11 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 8 def initialize(path) @path = path @data = load_json end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 6 def data @data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 5 def path @path end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 17 def [](key) @data[key] end |
#[]=(key, value) ⇒ Object
21 22 23 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 21 def []=(key, value) @data[key] = value end |
#empty? ⇒ Boolean
13 14 15 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 13 def empty? @data.empty? end |
#save! ⇒ Object
25 26 27 |
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 25 def save! File.open(@path, "w") { |f| f.write(JSON.pretty_generate(@data)) } end |