Class: GoogleCells::GoogleObject

Inherits:
Object
  • Object
show all
Defined in:
lib/google_cells/google_object.rb

Direct Known Subclasses

Author, Cell, Folder, Row, Spreadsheet, Worksheet

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribs = {}) ⇒ GoogleObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/google_cells/google_object.rb', line 16

def initialize(attribs={})
  @values = {}
  self.class.permanent_attributes.each{|a| @values[a] = attribs[a]}

  extra = attribs.keys - self.class.permanent_attributes
  extra.each do |a|
    if self.respond_to?("#{a}=")
      instance_variable_set("@#{a}".to_sym, attribs[a])
      next
    end
    raise ArgumentError, "invalid attribute #{a} passed to #{
      self.class}"
  end
end

Class Attribute Details

.permanent_attributesObject (readonly)

Returns the value of attribute permanent_attributes.



5
6
7
# File 'lib/google_cells/google_object.rb', line 5

def permanent_attributes
  @permanent_attributes
end

Class Method Details

.define_accessorsObject



7
8
9
10
11
12
13
# File 'lib/google_cells/google_object.rb', line 7

def define_accessors
  self.instance_eval do
    @permanent_attributes.each do |k|
      define_method(k){ @values[k] }
    end
  end
end