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:



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

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

Instance Method Details

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



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

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

#[](key) ⇒ Object



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

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

#[]=(key, value) ⇒ Object



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

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

#clearObject



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

def clear()
  for key in @list.keys
    self[key] = ""
  end
end

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

Returns:

  • (Boolean)


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

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

#input_value(key) ⇒ Object



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

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

#inspectObject



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

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

#numeric_value(key) ⇒ Object



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

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

#replace(hash) ⇒ Object



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

def replace(hash)
  clear()
  update(hash)
end

#to_hashObject



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

def to_hash()
  result = {}
  for key in @list.keys
    result[key] = self[key]
  end
  return result
end

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



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

def update(hash)
  for k, v in hash
    self[k] = v
  end
end