Class: Reflex::View

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
HasFrame, HasTags, 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

#frame, #frame=, #inset_by, #move_by, #move_to, #resize_by, #resize_to

Methods included from Hookable

#hook

Constructor Details

#initialize(opts = {}, &block) ⇒ View

Returns a new instance of View.



39
40
41
42
43
# File 'lib/reflex/view.rb', line 39

def initialize (opts = {}, &block)
  super()
  set opts
  @attach_block = block if block
end

Class Method Details

.has_modelObject



81
82
83
# File 'lib/reflex/view.rb', line 81

def self.has_model ()
  include ModelView
end

Instance Method Details

#capture(*args) ⇒ Object



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

def capture (*args)
  send :capture=, *args unless args.empty?
  CAPTURE_FLAG.bits2symbols get_capture
end

#capture=(*args) ⇒ Object



59
60
61
# File 'lib/reflex/view.rb', line 59

def capture= (*args)
  set_capture CAPTURE_FLAG.symbols2bits(*args.flatten)
end

#capturing?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

def capturing? (*args)
  cap = capture
  args.all? {|type| cap.include? type}
end

#childrenObject



45
46
47
# File 'lib/reflex/view.rb', line 45

def children ()
  to_enum :each_child
end

#gravity=(*args) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/reflex/view.rb', line 73

def gravity= (*args)
  case arg = args[0]
  when Point then set_gravity arg.x, arg.y
  when Array then set_gravity arg[0], arg[1]
  else            set_gravity *args
  end
end

#style(*args, &block) ⇒ Object



53
54
55
56
57
# File 'lib/reflex/view.rb', line 53

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



49
50
51
# File 'lib/reflex/view.rb', line 49

def styles ()
  to_enum :each_style
end