Class: Mayl::Commands::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/mayl/commands/set.rb

Overview

Public: The Set command accepts a key and asks the user to type in the translations for that key in each of the locales.

Example

command = Set.new(env, 'activerecord.models.post')
command.execute
  ca: <type something>
  en: <type something>
# Now locales have those values set.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, key) ⇒ Set

Public: Initializes a new Set command.

env - the global environment key - the String key to be set



21
22
23
24
# File 'lib/mayl/commands/set.rb', line 21

def initialize(env, key)
  @env = env
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



15
16
17
# File 'lib/mayl/commands/set.rb', line 15

def key
  @key
end

Instance Method Details

#executeObject

Public: Executes the command, iterating over each locale, asking the user for a value, and setting it.

Returns the key.



30
31
32
33
34
35
36
# File 'lib/mayl/commands/set.rb', line 30

def execute
  locales.each do |locale|
    print "  #{locale.to_s}: "
    locale.set qualified_key, gets.chomp
  end
  @key
end