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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ListRow.



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

def initialize(list, index)
  @list = list
  @index = index
end

Instance Method Details

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



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

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

#[](key) ⇒ Object



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

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

#[]=(key, value) ⇒ Object



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

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

#clearObject



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

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

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

Returns:

  • (Boolean)


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

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

#input_value(key) ⇒ Object



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

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

#inspectObject



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

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

#numeric_value(key) ⇒ Object



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

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

#replace(hash) ⇒ Object



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

def replace(hash)
  clear
  update(hash)
end

#to_hashObject



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

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

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



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

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