diff options
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/core.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/model/model.rb | 1 | ||||
-rw-r--r-- | lib/oxidized/string.rb | 13 |
3 files changed, 15 insertions, 0 deletions
diff --git a/lib/oxidized/core.rb b/lib/oxidized/core.rb index 3c728b6..b4f5612 100644 --- a/lib/oxidized/core.rb +++ b/lib/oxidized/core.rb @@ -1,5 +1,6 @@ module Oxidized require 'oxidized/log' + require 'oxidized/string' require 'oxidized/config' require 'oxidized/worker' require 'oxidized/nodes' diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index ca08332..dc7d18a 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -76,6 +76,7 @@ module Oxidized def cmd string, &block out = @input.cmd string return false unless out + out = Oxidized::String out self.class.cmds[:all].each do |all_block| out = instance_exec out, string, &all_block end diff --git a/lib/oxidized/string.rb b/lib/oxidized/string.rb new file mode 100644 index 0000000..b334eaa --- /dev/null +++ b/lib/oxidized/string.rb @@ -0,0 +1,13 @@ +module Oxidized + # Used in models, contains convenience methods + class String < String + # @return [Oxidized::String] copy of self with last line removed + def pop + Oxy::String.new each_line.to_a[0..-2].join + end + # @return [Oxidized::String] copy of self with first line removed + def shift + Oxy::String.new each_line.to_a[1..-1].join + end + end +end |