Module: Lazier
- Defined in:
- lib/lazier.rb,
lib/lazier/math.rb,
lib/lazier/hash.rb,
lib/lazier/string.rb,
lib/lazier/object.rb,
lib/lazier/boolean.rb,
lib/lazier/version.rb,
lib/lazier/pathname.rb,
lib/lazier/settings.rb,
lib/lazier/datetime.rb,
lib/lazier/exceptions.rb
Overview
This file is part of the lazier gem. Copyright (C) 2013 and above Shogun
Defined Under Namespace
Modules: Boolean, DateTime, Exceptions, Hash, Math, Object, Pathname, String, TimeZone, Version Classes: Settings
Class Method Summary (collapse)
-
+ (R18N::Translation) i18n
Get the list of available translation for the current locale.
-
+ (Settings) load!(*what)
Loads the extensions.
-
+ (Object) load_boolean
Loads Boolean extensions.
-
+ (Object) load_datetime
Loads DateTime extensions.
-
+ (Object) load_hash
Loads Hash extensions.
-
+ (Object) load_math
Loads Math extensions.
-
+ (Object) load_object
Loads Object extensions.
-
+ (Object) load_pathname
Loads Pathname extensions.
-
+ (Object) load_string
Loads String extensions.
-
+ (R18n::Translation) localize(locale = nil)
Set the current locale for messages.
-
+ (Boolean) localized?
Check whether the i18n support have been enabled.
-
+ (Settings) settings
Returns the settings for the extensions.
Class Method Details
+ (R18N::Translation) i18n
Get the list of available translation for the current locale.
132 133 134 135 |
# File 'lib/lazier.rb', line 132 def self.i18n Lazier.localize if !Lazier.localized? @i18n end |
+ (Settings) load!(*what)
Loads the extensions.
46 47 48 49 50 51 52 53 54 |
# File 'lib/lazier.rb', line 46 def self.load!(*what) ::Lazier.localize if !Lazier.localized? what = ["object", "boolean", "string", "hash", "datetime", "math", "pathname"] if what.count == 0 what.collect! { |w| ::Lazier.send("load_#{w}") } yield if block_given? ::Lazier::Settings.instance end |
+ (Object) load_boolean
Loads Boolean extensions.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/lazier.rb', line 64 def self.load_boolean ::TrueClass.class_eval do include ::Lazier::Object include ::Lazier::Boolean end ::FalseClass.class_eval do include ::Lazier::Object include ::Lazier::Boolean end end |
+ (Object) load_datetime
Loads DateTime extensions.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/lazier.rb', line 91 def self.load_datetime Lazier.load_object ::Time.class_eval do include ::Lazier::DateTime end ::Date.class_eval do include ::Lazier::DateTime end ::DateTime.class_eval do include ::Lazier::DateTime end ::ActiveSupport::TimeZone.class_eval do include ::Lazier::TimeZone end end |
+ (Object) load_hash
Loads Hash extensions.
84 85 86 87 88 |
# File 'lib/lazier.rb', line 84 def self.load_hash ::Hash.class_eval do include ::Lazier::Hash end end |
+ (Object) load_math
Loads Math extensions.
112 113 114 115 116 117 118 |
# File 'lib/lazier.rb', line 112 def self.load_math Lazier.load_object ::Math.class_eval do include ::Lazier::Math end end |
+ (Object) load_object
Loads Object extensions.
57 58 59 60 61 |
# File 'lib/lazier.rb', line 57 def self.load_object ::Object.class_eval do include ::Lazier::Object end end |
+ (Object) load_pathname
Loads Pathname extensions.
121 122 123 124 125 126 127 |
# File 'lib/lazier.rb', line 121 def self.load_pathname require "pathname" ::Pathname.class_eval do include ::Lazier::Pathname end end |
+ (Object) load_string
Loads String extensions.
77 78 79 80 81 |
# File 'lib/lazier.rb', line 77 def self.load_string ::String.class_eval do include ::Lazier::String end end |
+ (R18n::Translation) localize(locale = nil)
Set the current locale for messages.
141 142 143 144 |
# File 'lib/lazier.rb', line 141 def self.localize(locale = nil) @i18n_locales_path ||= ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../locales/") @i18n = R18n::I18n.new([locale, ENV["LANG"], R18n::I18n.system_locale].compact, @i18n_locales_path).t.lazier end |
+ (Boolean) localized?
Check whether the i18n support have been enabled.
149 150 151 |
# File 'lib/lazier.rb', line 149 def self.localized? @i18n.present? end |
+ (Settings) settings
Returns the settings for the extensions.
29 30 31 32 |
# File 'lib/lazier.rb', line 29 def self.settings ::Lazier.localize if !Lazier.localized? ::Lazier::Settings.instance end |