Class: GoogleDriveV0::ListRow

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

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(list, index) ⇒ ListRow

:nodoc:



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

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

Instance Method Details

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



75
76
77
# File 'lib/google_drive_v0/list_row.rb', line 75

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

#[](key) ⇒ Object



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

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

#[]=(key, value) ⇒ Object



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

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

#clearObject



61
62
63
64
65
# File 'lib/google_drive_v0/list_row.rb', line 61

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

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

Returns:

  • (Boolean)


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

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

#inspectObject



82
83
84
# File 'lib/google_drive_v0/list_row.rb', line 82

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

#numeric_value(key) ⇒ Object



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

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

#replace(hash) ⇒ Object



56
57
58
59
# File 'lib/google_drive_v0/list_row.rb', line 56

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

#to_hashObject



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

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

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



48
49
50
51
52
# File 'lib/google_drive_v0/list_row.rb', line 48

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