Class: Aio::Text::MatchStringInfo

Inherits:
Struct
  • Object
show all
Defined in:
lib/aio/core/text/match_string_info.rb

Overview

将提取的关键信息附带的增加所在上下文以及行数

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(var, content, line) ⇒ MatchStringInfo

Returns a new instance of MatchStringInfo.



9
10
11
12
13
14
15
# File 'lib/aio/core/text/match_string_info.rb', line 9

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/aio/core/text/match_string_info.rb', line 62

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

Instance Attribute Details

#compare_valObject

存放比较后的不同值,也是 MachStringInfo 类



7
8
9
# File 'lib/aio/core/text/match_string_info.rb', line 7

def compare_val
  @compare_val
end

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



4
5
6
# File 'lib/aio/core/text/match_string_info.rb', line 4

def content
  @content
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



4
5
6
# File 'lib/aio/core/text/match_string_info.rb', line 4

def line
  @line
end

#varObject

Returns the value of attribute var

Returns:

  • (Object)

    the current value of var



4
5
6
# File 'lib/aio/core/text/match_string_info.rb', line 4

def var
  @var
end

Instance Method Details

#compare_contentObject

差异值的文本



49
50
51
# File 'lib/aio/core/text/match_string_info.rb', line 49

def compare_content
  compare_val.content
end

#compare_lineObject

差异值的行数



54
55
56
# File 'lib/aio/core/text/match_string_info.rb', line 54

def compare_line
  compare_val.line
end

#compare_val?Boolean

判断是否有compare_val值

Returns:

  • (Boolean)


44
45
46
# File 'lib/aio/core/text/match_string_info.rb', line 44

def compare_val?
  !@compare_val.nil?
end

#eql?(other_match) ⇒ Boolean

覆盖原有的eql?

Returns:

  • (Boolean)


26
27
28
# File 'lib/aio/core/text/match_string_info.rb', line 26

def eql?(other_match)
  self.to_s.eql?(other_match.to_s)
end

#inspectObject



17
18
19
# File 'lib/aio/core/text/match_string_info.rb', line 17

def inspect
  var.to_s
end

#same_content?(other_match) ⇒ Boolean

判断和另一个class是否是同一个content

Returns:

  • (Boolean)


31
32
33
# File 'lib/aio/core/text/match_string_info.rb', line 31

def same_content?(other_match)
  content == other_match.content
end

#same_line?(other_match) ⇒ Boolean

判断是否和另一个值为同一行

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'lib/aio/core/text/match_string_info.rb', line 36

def same_line?(other_match)
  if same_content?
    return line == other_match.line
  end
  return false
end

#to_sObject



21
22
23
# File 'lib/aio/core/text/match_string_info.rb', line 21

def to_s
 var 
end