Class: Gobbler::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gobbler/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Base

Returns a new instance of Base.



9
10
11
# File 'lib/gobbler/base.rb', line 9

def initialize(json)
  @json = json
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gobbler/base.rb', line 17

def method_missing(method, *args, &block)
  if base_attr.keys.include?(method.to_s) || method == :assets
    if method == :assets && base_attr.keys.include?("assets_packed")
      ::Gobbler.unpack(base_attr["assets_packed"])
    else
      base_attr[method.to_s]
    end
  else
    super(method, *args, &block)
  end
end

Instance Attribute Details

#jsonObject

Returns the value of attribute json.



3
4
5
# File 'lib/gobbler/base.rb', line 3

def json
  @json
end

Class Method Details

.get(guid) ⇒ Object



5
6
7
# File 'lib/gobbler/base.rb', line 5

def self.get(guid)
  list.find {|p| p.guid == guid}
end

Instance Method Details

#base_attrObject



13
# File 'lib/gobbler/base.rb', line 13

def base_attr; json; end