Class: Sumodev::Commands::Push::AuthorizedKeys
- Inherits:
-
Object
- Object
- Sumodev::Commands::Push::AuthorizedKeys
- Defined in:
- lib/sumodev/commands/push.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
Instance Method Summary collapse
- #add(key) ⇒ Object
-
#initialize(file_contents) ⇒ AuthorizedKeys
constructor
A new instance of AuthorizedKeys.
- #remove(key) ⇒ Object
- #to_io ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file_contents) ⇒ AuthorizedKeys
Returns a new instance of AuthorizedKeys.
97 98 99 |
# File 'lib/sumodev/commands/push.rb', line 97 def initialize(file_contents) @contents = parse!(file_contents) end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
95 96 97 |
# File 'lib/sumodev/commands/push.rb', line 95 def contents @contents end |
Instance Method Details
#add(key) ⇒ Object
101 102 103 |
# File 'lib/sumodev/commands/push.rb', line 101 def add key @contents[key[:key]] = key end |
#remove(key) ⇒ Object
105 106 107 |
# File 'lib/sumodev/commands/push.rb', line 105 def remove key @contents.delete(key[:key]) end |
#to_io ⇒ Object
115 116 117 |
# File 'lib/sumodev/commands/push.rb', line 115 def to_io StringIO.new(to_s) end |
#to_s ⇒ Object
109 110 111 112 113 |
# File 'lib/sumodev/commands/push.rb', line 109 def to_s @contents.collect do |identity, k| "#{k[:optional]}ssh-#{k[:protocol]} #{k[:key]} #{k[:identity]}\n" end.join end |