Sha256: d7f329f633c76cc56fb5f8b609fb69b6083d1cb71bdb2b92f2cad76c57ed2335
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
require 'vedeu/output/esc' module Vedeu # Represents the concept of a visible or invisible attribute. # class Visible # @param value [Boolean|Symbol] # @return [Visible] def self.coerce(value) if value.is_a?(self) value else new(value) end end # @param visible [Boolean|Symbol] # @return [Visible] def initialize(visible = nil) @visible = if visible == :hide || visible == false false elsif visible == :show || visible == true true else !!visible end 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.4.5 | lib/vedeu/support/visible.rb |
vedeu-0.4.4 | lib/vedeu/support/visible.rb |