Class: GoogleDrive::ListRow

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/google_drive/list_row.rb

Overview

Hash-like object returned by GoogleDrive::List#[].

Instance Method Summary collapse

Constructor Details

#initialize(list, index) ⇒ ListRow

:nodoc:



20
21
22
23
# File 'lib/google_drive/list_row.rb', line 20

def initialize(list, index) #:nodoc:
  @list = list
  @index = index
end

Instance Method Details

#==(other) ⇒ Object Also known as: ===, eql?



76
77
78
# File 'lib/google_drive/list_row.rb', line 76

def ==(other)
  self.class == other.class && to_hash == other.to_hash
end

#[](key) ⇒ Object



25
26
27
# File 'lib/google_drive/list_row.rb', line 25

def [](key)
  @list.get(@index, key)
end

#[]=(key, value) ⇒ Object



37
38
39
# File 'lib/google_drive/list_row.rb', line 37

def []=(key, value)
  @list.set(@index, key, value)
end

#clearObject



62
63
64
65
66
# File 'lib/google_drive/list_row.rb', line 62

def clear
  @list.keys.each do |key|
    self[key] = ''
  end
end

#has_key?(key) ⇒ Boolean Also known as: include?, key?, member?

Returns:

  • (Boolean)


41
42
43
# File 'lib/google_drive/list_row.rb', line 41

def has_key?(key)
  @list.keys.include?(key)
end

#input_value(key) ⇒ Object



33
34
35
# File 'lib/google_drive/list_row.rb', line 33

def input_value(key)
  @list.input_value(@index, key)
end

#inspectObject



83
84
85
# File 'lib/google_drive/list_row.rb', line 83

def inspect
  "\#<%p %p>" % [self.class, to_hash]
end

#numeric_value(key) ⇒ Object



29
30
31
# File 'lib/google_drive/list_row.rb', line 29

def numeric_value(key)
  @list.numeric_value(@index, key)
end

#replace(hash) ⇒ Object



57
58
59
60
# File 'lib/google_drive/list_row.rb', line 57

def replace(hash)
  clear
  update(hash)
end

#to_hashObject



68
69
70
71
72
73
74
# File 'lib/google_drive/list_row.rb', line 68

def to_hash
  result = {}
  @list.keys.each do |key|
    result[key] = self[key]
  end
  result
end

#update(hash) ⇒ Object Also known as: merge!



49
50
51
52
53
# File 'lib/google_drive/list_row.rb', line 49

def update(hash)
  hash.each do |k, v|
    self[k] = v
  end
end