summaryrefslogtreecommitdiff
path: root/lib/oxidized/string.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/string.rb')
-rw-r--r--lib/oxidized/string.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/oxidized/string.rb b/lib/oxidized/string.rb
index 35dc5af..4bdfbf2 100644
--- a/lib/oxidized/string.rb
+++ b/lib/oxidized/string.rb
@@ -1,13 +1,32 @@
module Oxidized
# Used in models, contains convenience methods
class String < String
+ attr_accessor :type, :cmd, :name
+
# @return [Oxidized::String] copy of self with last line removed
def cut_tail
Oxidized::String.new each_line.to_a[0..-2].join
end
+
# @return [Oxidized::String] copy of self with first line removed
def cut_head
Oxidized::String.new each_line.to_a[1..-1].join
end
+
+ # sets @cmd and @name unless @name is already set
+ def set_cmd command
+ @cmd = command
+ @name = @cmd.strip.gsub(/\s+/, '_') if @name == nil
+ end
+
+ def initialize str=''
+ super
+ if str.class == Oxidized::String
+ @cmd = str.cmd
+ @name = str.name
+ @type = str.type
+ end
+ end
+
end
end