Sha256: 634337ae4bba16a7feb0b3ad04f6d89e989b65f374369a28f846c4c5a19c2470
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
require 'vedeu/support/esc' module Vedeu # Represents the concept of a visible or invisible attribute. # class Visible # @return [Visible] def self.coerce(value) if value.is_a?(self) value else new(value) end end # @return [Visible] def initialize(visible = nil) @visible = if visible == :hide || visible == false false elsif visible == :show || visible == true true else !!visible end end # Returns log friendly output. # # @return [String] def inspect "<#{self.class.name} (#{@visible.to_s})>" end # @return [String] def cursor if visible? Esc.string('show_cursor') else Esc.string('hide_cursor') end end # @return [Boolean] def visible? @visible end # @return [Boolean] def invisible? !@visible end # @return [Visible] def hide Visible.new(false) end # @return [Visible] def show Visible.new(true) end # @return [Visible] def toggle visible? ? hide : show end end # Visible end # Vedeu
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.1 | lib/vedeu/support/visible.rb |
vedeu-0.4.0 | lib/vedeu/support/visible.rb |
vedeu-0.3.5 | lib/vedeu/support/visible.rb |