Class: Reflex::View

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
HasFrame, HasTags, Xot::Hookable, Xot::Setter
Defined in:
lib/reflex/view.rb

Direct Known Subclasses

Button, ListView, TextView

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasTags

#clear_tags, #tag, #tag=, #tags, #untag

Methods included from HasFrame

#inset_by, #move_by, #move_to, #resize_by, #resize_to

Constructor Details

#initialize(options = nil, &block) ⇒ View

Returns a new instance of View.



55
56
57
58
59
# File 'lib/reflex/view.rb', line 55

def initialize(options = nil, &block)
  super()
  set options if options
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
end

Class Method Details

.has_modelObject



146
147
148
# File 'lib/reflex/view.rb', line 146

def self.has_model()
  include ModelView
end

Instance Method Details

#capturing?(*args) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
104
105
106
107
108
109
110
# File 'lib/reflex/view.rb', line 101

def capturing?(*args)
  args, cap = args.flatten, capture
  if args.empty?
    not cap.empty?
  elsif args.include?(:all)
    cap == [:key, :pointer]
  else
    args.all? {|type| cap.include? type}
  end
end

#childrenObject



83
84
85
# File 'lib/reflex/view.rb', line 83

def children()
  to_enum :each_child
end

#delay(seconds = 0, &block) ⇒ Object



71
72
73
# File 'lib/reflex/view.rb', line 71

def delay(seconds = 0, &block)
  timeout seconds, &block
end

#find_child(*args) ⇒ Object Also known as: find



79
80
81
# File 'lib/reflex/view.rb', line 79

def find_child(*args)
  find_children(*args).first
end

#interval(seconds = 0, &block) ⇒ Object



67
68
69
# File 'lib/reflex/view.rb', line 67

def interval(seconds = 0, &block)
  timeout seconds, count: -1, &block
end

#on_contact(e) ⇒ Object



112
113
# File 'lib/reflex/view.rb', line 112

def on_contact(e)
end

#on_contact_begin(e) ⇒ Object



115
116
# File 'lib/reflex/view.rb', line 115

def on_contact_begin(e)
end

#on_contact_end(e) ⇒ Object



118
119
# File 'lib/reflex/view.rb', line 118

def on_contact_end(e)
end

#remove_selfObject



75
76
77
# File 'lib/reflex/view.rb', line 75

def remove_self()
  parent.remove self if parent
end

#shapesObject



97
98
99
# File 'lib/reflex/view.rb', line 97

def shapes()
  to_enum :each_shape
end

#style(*args, &block) ⇒ Object



91
92
93
94
95
# File 'lib/reflex/view.rb', line 91

def style(*args, &block)
  s = get_style args.empty? ? nil : Selector.selector(*args)
  Xot::BlockUtil.instance_eval_or_block_call s, &block if block
  s
end

#stylesObject



87
88
89
# File 'lib/reflex/view.rb', line 87

def styles()
  to_enum :each_style
end

#timeout(seconds = 0, count: 1, &block) ⇒ Object



61
62
63
64
65
# File 'lib/reflex/view.rb', line 61

def timeout(seconds = 0, count: 1, &block)
  timer = start_timer seconds, count
  timer.block = block if block
  timer
end