Class: Moon::RenderArray

Inherits:
RenderContainer show all
Defined in:
lib/moon/packages/render_primitives/render_array.rb

Direct Known Subclasses

SelectiveRenderArray

Instance Attribute Summary

Attributes inherited from RenderContext

#id

Attributes included from Moon::RenderPrimitive::DataAttributes

#data_attrs

Attributes included from Moon::RenderPrimitive::Rectangular

#h, #position, #w

Attributes included from Moon::RenderPrimitive::Containable

#parent

Instance Method Summary collapse

Methods inherited from RenderContainer

#add, #clear_elements, #each, #h, #h=, #on_resize, #ppd_rc, #remove, #w, #w=

Methods inherited from RenderContext

#apply_position_modifier, #post_initialize, #pre_initialize, #render?, #render_abs, #render_content, #screen_bounds, #screen_position, #update

Methods included from Moon::RenderPrimitive::DataAttributes

#initialize_data_attrs

Methods included from Moon::RenderPrimitive::Rectangular

#align!, #bounds, #contains?, #cx, #cx=, #cy, #cy=, #move, #on_resize, #resize, #to_rect, #x, #x2, #x2=, #x=, #y, #y2, #y2=, #y=, #z, #z=

Methods included from Moon::RenderPrimitive::Containable

#containerize, #disown

Methods included from Moon::RenderPrimitive::Visibility

#hide, #invisible?, #show, #visible?

Methods included from Moon::RenderPrimitive::Renderable

#render, #render?

Methods included from Moon::RenderPrimitive::ScreenElement

#contains_pos?, #relative_contains_pos?, #relative_to_screen, #screen_to_relative

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #trigger, #typing

Methods included from Transitionable

#key_transition, #remove_transitions, #transition

Methods included from TransitionHost

#add_transition, #finish_transitions, #remove_transition, #remove_transitions, #update_transitions

Constructor Details

#initialize(size = nil) ⇒ RenderArray

Returns a new instance of RenderArray.


5
6
7
8
9
10
11
12
# File 'lib/moon/packages/render_primitives/render_array.rb', line 5

def initialize(size = nil)
  super()
  if size && block_given?
    size.times do |i|
      add(yield i)
    end
  end
end

Instance Method Details

#<<(e) ⇒ Object


35
36
37
38
# File 'lib/moon/packages/render_primitives/render_array.rb', line 35

def <<(e)
  add(e)
  self
end

#[](index) ⇒ Object


14
15
16
# File 'lib/moon/packages/render_primitives/render_array.rb', line 14

def [](index)
  @elements[index]
end

#[]=(index, e) ⇒ Object


18
19
20
21
# File 'lib/moon/packages/render_primitives/render_array.rb', line 18

def []=(index, e)
  @elements[index] = e
  e.parent = self
end

#clearObject


53
54
55
56
# File 'lib/moon/packages/render_primitives/render_array.rb', line 53

def clear
  @elements.each(&:disown)
  @elements.clear
end

#concat(array) ⇒ Object


49
50
51
# File 'lib/moon/packages/render_primitives/render_array.rb', line 49

def concat(array)
  array.each { |e| add(e) }; self
end

#delete(e) ⇒ Object


45
46
47
# File 'lib/moon/packages/render_primitives/render_array.rb', line 45

def delete(e)
  remove(e)
end

#popObject


70
71
72
73
74
# File 'lib/moon/packages/render_primitives/render_array.rb', line 70

def pop
  element = @elements.pop
  element.disown
  element
end

#push(e) ⇒ Object


40
41
42
43
# File 'lib/moon/packages/render_primitives/render_array.rb', line 40

def push(e)
  add(e)
  self
end

#reject!(&block) ⇒ Object


29
30
31
32
33
# File 'lib/moon/packages/render_primitives/render_array.rb', line 29

def reject!(&block)
  rejected = @elements.reject!(&block)
  rejected.each(&:disown)
  self
end

#select!(&block) ⇒ Object


23
24
25
26
27
# File 'lib/moon/packages/render_primitives/render_array.rb', line 23

def select!(&block)
  rejected = @elements.select!(&block)
  rejected.each(&:disown)
  self
end

#shiftObject


64
65
66
67
68
# File 'lib/moon/packages/render_primitives/render_array.rb', line 64

def shift
  element = @elements.shift
  element.disown
  element
end

#sizeObject Also known as: length


76
77
78
# File 'lib/moon/packages/render_primitives/render_array.rb', line 76

def size
  @elements.size
end

#unshift(e) ⇒ Object


58
59
60
61
62
# File 'lib/moon/packages/render_primitives/render_array.rb', line 58

def unshift(e)
  @elements.unshift(e)
  e.parent = self
  self
end