Sha256: 2d44d5fbf0038b0716620e38a16780b2ca4e05a84f12e66fbf4394b1632ac90b

Contents?: true

Size: 759 Bytes

Versions: 21

Compression:

Stored size: 759 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+/, '_')
    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

21 entries across 21 versions & 1 rubygems

Version Path
oxidized-0.21.0 lib/oxidized/string.rb
oxidized-0.20.0 lib/oxidized/string.rb
oxidized-0.19.0 lib/oxidized/string.rb
oxidized-0.18.0 lib/oxidized/string.rb
oxidized-0.17.0 lib/oxidized/string.rb
oxidized-0.16.3 lib/oxidized/string.rb
oxidized-0.16.2 lib/oxidized/string.rb
oxidized-0.16.1 lib/oxidized/string.rb
oxidized-0.16.0 lib/oxidized/string.rb
oxidized-0.15.0 lib/oxidized/string.rb
oxidized-0.14.3 lib/oxidized/string.rb
oxidized-0.14.2 lib/oxidized/string.rb
oxidized-0.14.1 lib/oxidized/string.rb
oxidized-0.14.0 lib/oxidized/string.rb
oxidized-0.13.1 lib/oxidized/string.rb
oxidized-0.13.0 lib/oxidized/string.rb
oxidized-0.12.2 lib/oxidized/string.rb
oxidized-0.12.1 lib/oxidized/string.rb
oxidized-0.12.0 lib/oxidized/string.rb
oxidized-0.11.0 lib/oxidized/string.rb