Class: Mayl::Commands::Get
- Inherits:
-
Object
- Object
- Mayl::Commands::Get
- Defined in:
- lib/mayl/commands/get.rb
Overview
Public: The Get command accepts a key and returns a summary of the values for that key in every locale.
Example
command = Get.new(env, 'activerecord.models.post')
command.execute
# Outputs:
# ca: Article
# es: ArtÃculo
# en: Post
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#execute ⇒ Object
Public: Executes the command, iterating over each locale, asking the value for the key, and printing it out.
-
#initialize(env, key) ⇒ Get
constructor
Public: Initializes a new Get command.
Constructor Details
#initialize(env, key) ⇒ Get
Public: Initializes a new Get command.
env - the global environment key - the String key to get the value of
22 23 24 25 |
# File 'lib/mayl/commands/get.rb', line 22 def initialize(env, key) @env = env @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
16 17 18 |
# File 'lib/mayl/commands/get.rb', line 16 def key @key end |
Instance Method Details
#execute ⇒ Object
Public: Executes the command, iterating over each locale, asking the value for the key, and printing it out.
Returns the key.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mayl/commands/get.rb', line 31 def execute locales.each do |locale| result = locale.get qualified_key name = locale.to_s if result.is_a? String print " #{name}: #{result}\n" else print " #{name}: (empty)\n" end end @key end |