Sha256: aa348aef8b36fd419b4a2512bd0cb230de38a804979599965a1c4beae50a5ed7

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

module Aio::Text

  # 将提取的关键信息附带的增加所在上下文以及行数
  class MatchStringInfo < Struct.new(:var, :content, :line)

    # 存放比较后的不同值,也是 MachStringInfo 类
    attr_accessor :compare_val

    def initialize(var, content, line)
      super(
        var,
        content,
        line
      )
    end

    def inspect
      var.to_s
    end

    def to_s
     var 
    end

    # 覆盖原有的eql?
    def eql?(other_match)
      self.to_s.eql?(other_match.to_s)
    end

    # 判断和另一个class是否是同一个content
    def same_content?(other_match)
      content == other_match.content
    end

    # 判断是否和另一个值为同一行
    def same_line?(other_match)
      if same_content?
        return line == other_match.line
      end
      return false
    end

    # 判断是否有compare_val值
    def compare_val?
      !@compare_val.nil?
    end

    # 差异值的文本
    def compare_content
      compare_val.content
    end

    # 差异值的行数
    def compare_line
      compare_val.line
    end

    def var;  self[:var].to_s;     end
    def content; self[:content]; end
    def line;    self[:line];    end

    def method_missing(m, *args)
      if var.respond_to?(m)
        var.send(m, *args)
      
      else
        super
      end
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aio_elin-1.1.8 lib/aio/core/text/match_string_info.rb
aio_elin-1.1.7 lib/aio/core/text/match_string_info.rb
aio_elin-1.1.4 lib/aio/core/text/match_string_info.rb
aio_elin-1.1.3 lib/aio/core/text/match_string_info.rb
aio_elin-1.1.2 lib/aio/core/text/match_string_info.rb
aio_elin-1.1.1 lib/aio/core/text/match_string_info.rb
aio_elin-1.1.0 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.9 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.8 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.7 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.6 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.5 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.4 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.3 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.2 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.1 lib/aio/core/text/match_string_info.rb
aio_elin-1.0.0 lib/aio/core/text/match_string_info.rb