Sha256: a0c31fd3f1289afe9783397dc2134c6b4b8efd818b4587296d8f2f310602cdbf

Contents?: true

Size: 773 Bytes

Versions: 12

Compression:

Stored size: 773 Bytes

Contents

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
oxidized-0.9.0 lib/oxidized/string.rb
oxidized-0.8.1 lib/oxidized/string.rb
oxidized-0.8.0 lib/oxidized/string.rb
oxidized-0.7.2 lib/oxidized/string.rb
oxidized-0.7.1 lib/oxidized/string.rb
oxidized-0.7.0 lib/oxidized/string.rb
oxidized-0.6.0 lib/oxidized/string.rb
oxidized-0.5.0 lib/oxidized/string.rb
oxidized-0.4.1 lib/oxidized/string.rb
oxidized-0.4.0 lib/oxidized/string.rb
oxidized-0.3.0 lib/oxidized/string.rb
oxidized-0.2.4 lib/oxidized/string.rb