Class: Ec2ssh::SshConfig::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/ec2ssh/ssh_config.rb

Constant Summary collapse

HEADER =
"# section:"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, text = '') ⇒ Section

Returns a new instance of Section.



83
84
85
86
# File 'lib/ec2ssh/ssh_config.rb', line 83

def initialize(name, text = '')
  @name = name
  @text = text
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



80
81
82
# File 'lib/ec2ssh/ssh_config.rb', line 80

def name
  @name
end

#textObject (readonly)

Returns the value of attribute text.



81
82
83
# File 'lib/ec2ssh/ssh_config.rb', line 81

def text
  @text
end

Instance Method Details

#append(text) ⇒ Object



88
89
90
# File 'lib/ec2ssh/ssh_config.rb', line 88

def append(text)
  @text << text
end

#replace!(text) ⇒ Object



92
93
94
# File 'lib/ec2ssh/ssh_config.rb', line 92

def replace!(text)
  @text = text
end

#to_sObject



96
97
98
99
100
101
102
103
104
105
# File 'lib/ec2ssh/ssh_config.rb', line 96

def to_s
  if text.empty?
    ""
  else
    "\#{HEADER} \#{@name}\n\#{@text}\n    EOS\n  end\nend\n"