Class: Rews::Folder::FindResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rews/folder.rb

Overview

find_* methods on Folder::BaseFolderId return a FindResult

Constant Summary collapse

VIEW_ATTRS =
[:includes_last_item_in_range,
:indexed_paging_offset,
:total_items_in_view]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, &proc) ⇒ FindResult

Returns a new instance of FindResult.



51
52
53
54
55
56
# File 'lib/rews/folder.rb', line 51

def initialize(view, &proc)
  VIEW_ATTRS.each do |attr|
    self.instance_variable_set("@#{attr}", view[attr])
  end
  @result = proc.call(view) if proc
end

Instance Attribute Details

#resultObject (readonly)

the result of the find_* call



49
50
51
# File 'lib/rews/folder.rb', line 49

def result
  @result
end

Instance Method Details

#[](key) ⇒ Object

access an element from result



69
70
71
# File 'lib/rews/folder.rb', line 69

def [](key)
  result[key]
end

#firstObject



73
74
75
# File 'lib/rews/folder.rb', line 73

def first
  result.first
end

#inspectObject



81
82
83
84
# File 'lib/rews/folder.rb', line 81

def inspect
  attrs = VIEW_ATTRS.map{|attr| "@#{attr}=#{self.send(attr)}"}.join(", ")
  "#<#{self.class} #{attrs}, @result=#{@result.inspect}>"
end

#lastObject



77
78
79
# File 'lib/rews/folder.rb', line 77

def last
  result.last
end

#lengthObject

count of items in the result



59
60
61
# File 'lib/rews/folder.rb', line 59

def length
  result.length
end

#sizeObject

alias for length



64
65
66
# File 'lib/rews/folder.rb', line 64

def size
  result.size
end