Class: Mayl::Commands::Edit
- Inherits:
-
Object
- Object
- Mayl::Commands::Edit
- Defined in:
- lib/mayl/commands/edit.rb
Overview
Public: The Edit command quickly edits the last value consulted with Get or Set.
Example
command = Edit.new(env, 'es', 'ArtÃculo')
command.execute
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#execute ⇒ Object
Public: Executes the command, editing the @key for the given @locale.
-
#initialize(env, locale, value) ⇒ Edit
constructor
Public: Initializes a new Get command.
Constructor Details
#initialize(env, locale, value) ⇒ Edit
Public: Initializes a new Get command.
env - the global environment locale - the locale that we want to edit value - the value to set
19 20 21 22 23 24 25 |
# File 'lib/mayl/commands/edit.rb', line 19 def initialize(env, locale, value) @env = env @key = @env.last_value raise ArgumentError, "You must get or set a key before calling edit" unless @key @locale = locale @value = value end |
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
12 13 14 |
# File 'lib/mayl/commands/edit.rb', line 12 def locale @locale end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
12 13 14 |
# File 'lib/mayl/commands/edit.rb', line 12 def value @value end |
Instance Method Details
#execute ⇒ Object
Public: Executes the command, editing the @key for the given @locale.
Returns the key.
30 31 32 33 34 35 36 37 38 |
# File 'lib/mayl/commands/edit.rb', line 30 def execute key = qualified_key locale = locales.detect do |locale| locale.name.to_s == @locale.to_s end locale.set key, @value key end |