Class: Selector

Inherits:
Object show all
Extended by:
Identifiable
Includes:
Identity, SelectorAcquire, SelectorQuery, SelectorRelinquish
Defined in:
tomes/components/selector/selector.rb

Overview

Note:

Stack-based functionality is experimental so it has been omitted. It can be added manually.

A mechanism for tracking two pieces of information at a time. For example, while dragging an item on screen a selector can track

both what the item is and the cursor's relative position to it.

Instance Attribute Summary collapse

Attributes included from Identity

#id

Instance Method Summary collapse

Methods included from Identifiable

id_counter, increment_id_counter, tag, tag=

Methods included from SelectorQuery

#blank?, #empty?, #has?, #knows?

Methods included from SelectorRelinquish

#drop, #forget, #reset!

Methods included from SelectorAcquire

#remember, #take

Methods included from Identity

#id_tag

Instance Attribute Details

#memoryObject

Returns the value of attribute memory.



43
# File 'tomes/components/selector/selector.rb', line 43

attr_reader :possession, :memory

#possessionObject

The convention is to use this attribute to represent “tangible” objects.

Returns:



43
44
45
# File 'tomes/components/selector/selector.rb', line 43

def possession
  @possession
end

Instance Method Details

#infoHash

A hash containing basic data about the selector.

@note This method will change (probably drastically) in a future update.

Returns:

  • (Hash)


48
49
50
51
52
53
54
55
# File 'tomes/components/selector/selector.rb', line 48

def info
  {
    self: self,
    id: id_tag,
    has: @possession,
    remembers: @memory
  }
end

#to_sString

A one-line string of some basic data about the selector.

Returns:

  • (String)


59
60
61
# File 'tomes/components/selector/selector.rb', line 59

def to_s
  '%<id>s - h: %<has>s | r: %<remembers>s | s: %<stack>s' % info
end