Class: Vedeu::Visible

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/support/visible.rb

Overview

Represents the concept of a visible or invisible attribute.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(visible = nil) ⇒ Visible



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vedeu/support/visible.rb', line 23

def initialize(visible = nil)
  @visible = if visible == :hide || visible == false
    false

  elsif visible == :show || visible == true
    true

  else
    !!visible

  end
end

Class Method Details

.coerce(value) ⇒ Visible



11
12
13
14
15
16
17
18
19
# File 'lib/vedeu/support/visible.rb', line 11

def self.coerce(value)
  if value.is_a?(self)
    value

  else
    new(value)

  end
end

Instance Method Details

#cursorString



37
38
39
40
41
42
43
44
45
# File 'lib/vedeu/support/visible.rb', line 37

def cursor
  if visible?
    Esc.string('show_cursor')

  else
    Esc.string('hide_cursor')

  end
end

#hideVisible



58
59
60
# File 'lib/vedeu/support/visible.rb', line 58

def hide
  Visible.new(false)
end

#invisible?Boolean



53
54
55
# File 'lib/vedeu/support/visible.rb', line 53

def invisible?
  !@visible
end

#showVisible



63
64
65
# File 'lib/vedeu/support/visible.rb', line 63

def show
  Visible.new(true)
end

#toggleVisible



68
69
70
# File 'lib/vedeu/support/visible.rb', line 68

def toggle
  visible? ? hide : show
end

#visible?Boolean



48
49
50
# File 'lib/vedeu/support/visible.rb', line 48

def visible?
  @visible
end