Module: Vedeu::Common Private
- Included in:
- Borders::Border, Borders::Refresh, Buffers::Refresh, Vedeu::Config::API, Vedeu::Cursors::Refresh, DSL::View, DSL::View, Editor::Cropper, Editor::Editor, EscapeSequences::Esc, Events::Aliases, Geometry::DSL, Geometry::Validator, Groups::Refresh, Input::DSL, Input::Mapper, Interfaces::Clear, Interfaces::DSL, Interfaces::DSL, Output::Compressor, Output::Wordwrap, Presentation::Style, Repositories::Model, Repositories::Repository, Repositories::Store, Runtime::Router, Templating::ViewTemplate, Terminal::Mode, Views::HTMLChar
- Defined in:
- lib/vedeu/common.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
A module for common methods used throughout Vedeu.
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
private
Returns a boolean indicating whether a variable is nil or empty.
-
#demodulize(klass) ⇒ String
private
Removes the module part from the expression in the string.
-
#present?(variable) ⇒ Boolean
private
Returns a boolean indicating whether a variable has a useful value.
-
#snake_case(name) ⇒ String
private
Converts a class name to a lowercase snake case string.
Instance Method Details
#absent?(variable) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
14 15 16 |
# File 'lib/vedeu/common.rb', line 14 def absent?(variable) !present?(variable) end |
#demodulize(klass) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes the module part from the expression in the string.
25 26 27 28 29 |
# File 'lib/vedeu/common.rb', line 25 def demodulize(klass) klass = klass.to_s klass[(klass.rindex('::') + 2)..-1] end |
#present?(variable) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
37 38 39 40 41 42 |
# File 'lib/vedeu/common.rb', line 37 def present?(variable) return true if variable.is_a?(Fixnum) return true unless variable.nil? || variable.empty? false end |
#snake_case(name) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
53 54 55 56 57 58 59 60 |
# File 'lib/vedeu/common.rb', line 53 def snake_case(name) name.gsub!(/::/, '/') name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') name.gsub!(/([a-z\d])([A-Z])/, '\1_\2') name.tr!('-', '_') name.downcase! name end |