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


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

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

Instance Method Details

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


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

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

#[](key) ⇒ Object


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

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

#[]=(key, value) ⇒ Object


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

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

#clearObject


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

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

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

Returns:

  • (Boolean)

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

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

#input_value(key) ⇒ Object


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

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

#inspectObject


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

def inspect
  format("\#<%p %p>", self.class, to_hash)
end

#numeric_value(key) ⇒ Object


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

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

#replace(hash) ⇒ Object


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

def replace(hash)
  clear
  update(hash)
end

#to_hashObject


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

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

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


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

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