Class: DiffMatchPatchES::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/diff_match_patch_es/options.rb,
sig/diff_match_patch_es/options.rbs

Constant Summary collapse

ATTRIBUTES =

Returns:

  • (Array[Symbol])
%i[
  diff_timeout
  diff_edit_cost
  match_threshold
  match_distance
  patch_delete_threshold
  patch_margin
  match_max_bits
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diff_timeout: 1.0, diff_edit_cost: 4, match_threshold: 0.5, match_distance: 1000, patch_delete_threshold: 0.5, patch_margin: 4, match_max_bits: 32) ⇒ Options

Returns a new instance of Options.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/diff_match_patch_es/options.rb', line 17

def initialize(
  diff_timeout: 1.0,
  diff_edit_cost: 4,
  match_threshold: 0.5,
  match_distance: 1000,
  patch_delete_threshold: 0.5,
  patch_margin: 4,
  match_max_bits: 32
)
  @diff_timeout = diff_timeout
  @diff_edit_cost = diff_edit_cost
  @match_threshold = match_threshold
  @match_distance = match_distance
  @patch_delete_threshold = patch_delete_threshold
  @patch_margin = patch_margin
  @match_max_bits = match_max_bits
end

Instance Attribute Details

#diff_edit_costInteger

Returns the value of attribute diff_edit_cost.

Returns:

  • (Integer)


7
8
9
# File 'sig/diff_match_patch_es/options.rbs', line 7

def diff_edit_cost
  @diff_edit_cost
end

#diff_timeoutNumeric

Returns the value of attribute diff_timeout.

Returns:

  • (Numeric)


5
6
7
# File 'sig/diff_match_patch_es/options.rbs', line 5

def diff_timeout
  @diff_timeout
end

#match_distanceInteger

Returns the value of attribute match_distance.

Returns:

  • (Integer)


11
12
13
# File 'sig/diff_match_patch_es/options.rbs', line 11

def match_distance
  @match_distance
end

#match_max_bitsInteger

Returns the value of attribute match_max_bits.

Returns:

  • (Integer)


17
18
19
# File 'sig/diff_match_patch_es/options.rbs', line 17

def match_max_bits
  @match_max_bits
end

#match_thresholdNumeric

Returns the value of attribute match_threshold.

Returns:

  • (Numeric)


9
10
11
# File 'sig/diff_match_patch_es/options.rbs', line 9

def match_threshold
  @match_threshold
end

#patch_delete_thresholdNumeric

Returns the value of attribute patch_delete_threshold.

Returns:

  • (Numeric)


13
14
15
# File 'sig/diff_match_patch_es/options.rbs', line 13

def patch_delete_threshold
  @patch_delete_threshold
end

#patch_marginInteger

Returns the value of attribute patch_margin.

Returns:

  • (Integer)


15
16
17
# File 'sig/diff_match_patch_es/options.rbs', line 15

def patch_margin
  @patch_margin
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


39
40
41
# File 'lib/diff_match_patch_es/options.rb', line 39

def ==(other)
  other.is_a?(Options) && to_h == other.to_h
end

#to_hHash[Symbol, Numeric]

Returns:

  • (Hash[Symbol, Numeric])


35
36
37
# File 'lib/diff_match_patch_es/options.rb', line 35

def to_h
  ATTRIBUTES.to_h { |name| [name, public_send(name)] }
end