Class: PodPrebuild::JSONFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-ht/helper/json.rb

Direct Known Subclasses

Metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/cocoapods-binary-ht/helper/json.rb', line 6

def data
  @data
end

#pathObject (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

Returns:

  • (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