Class: Oxidized::String

Inherits:
String
  • Object
show all
Defined in:
lib/oxidized/string.rb

Overview

Used in models, contains convenience methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str = '') ⇒ String

Returns a new instance of String.



22
23
24
25
26
27
28
29
# File 'lib/oxidized/string.rb', line 22

def initialize str=''
  super
  if str.class == Oxidized::String
    @cmd  = str.cmd
    @name = str.name
    @type = str.type
  end
end

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



4
5
6
# File 'lib/oxidized/string.rb', line 4

def cmd
  @cmd
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/oxidized/string.rb', line 4

def name
  @name
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/oxidized/string.rb', line 4

def type
  @type
end

Instance Method Details

#cut_headOxidized::String

Returns copy of self with first line removed.

Returns:



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_tailOxidized::String

Returns copy of self with last line removed.

Returns:



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