Class: Oxidized::String
- Inherits:
-
String
- Object
- String
- Oxidized::String
- Defined in:
- lib/oxidized/string.rb
Overview
Used in models, contains convenience methods
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#cut_head ⇒ Oxidized::String
Copy of self with first line removed.
-
#cut_tail ⇒ Oxidized::String
Copy of self with last line removed.
-
#initialize(str = '') ⇒ String
constructor
A new instance of String.
-
#set_cmd(command) ⇒ Object
sets @cmd and @name unless @name is already set.
Constructor Details
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
4 5 6 |
# File 'lib/oxidized/string.rb', line 4 def cmd @cmd end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/oxidized/string.rb', line 4 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/oxidized/string.rb', line 4 def type @type end |
Instance Method Details
#cut_head ⇒ Oxidized::String
Returns copy of self with first line removed.
12 13 14 |
# File 'lib/oxidized/string.rb', line 12 def cut_head Oxidized::String.new each_line.to_a[1..-1].join end |
#cut_tail ⇒ Oxidized::String
Returns copy of self with last line removed.
7 8 9 |
# File 'lib/oxidized/string.rb', line 7 def cut_tail Oxidized::String.new each_line.to_a[0..-2].join end |
#set_cmd(command) ⇒ Object
sets @cmd and @name unless @name is already set
17 18 19 20 |
# File 'lib/oxidized/string.rb', line 17 def set_cmd command @cmd = command @name = @cmd.strip.gsub(/\s+/, '_') if @name == nil end |