Class: Linkify::Match

Inherits:
Object
  • Object
show all
Defined in:
lib/linkify-it-rb/index.rb

Overview

Match result. Single element of array, returned by [[LinkifyIt#match]]


Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, shift) ⇒ Match



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/linkify-it-rb/index.rb', line 202

def initialize(obj, shift)
  start = obj.__index__
  endt  = obj.__last_index__
  text  = obj.__text_cache__.slice(start...endt)

  # Match#schema -> String
  #
  # Prefix (protocol) for matched string.
  @schema    = obj.__schema__.downcase

  # Match#index -> Number
  #
  # First position of matched string.
  @index     = start + shift

  # Match#lastIndex -> Number
  #
  # Next position after matched string.
  @lastIndex = endt + shift

  # Match#raw -> String
  #
  # Matched string.
  @raw       = text

  # Match#text -> String
  #
  # Notmalized text of matched string.
  @text      = text

  # Match#url -> String
  #
  # Normalized url of matched string.
  @url       = text
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



200
201
202
# File 'lib/linkify-it-rb/index.rb', line 200

def index
  @index
end

#lastIndexObject

Returns the value of attribute lastIndex.



200
201
202
# File 'lib/linkify-it-rb/index.rb', line 200

def lastIndex
  @lastIndex
end

#rawObject

Returns the value of attribute raw.



200
201
202
# File 'lib/linkify-it-rb/index.rb', line 200

def raw
  @raw
end

#schemaObject

Returns the value of attribute schema.



200
201
202
# File 'lib/linkify-it-rb/index.rb', line 200

def schema
  @schema
end

#textObject

Returns the value of attribute text.



200
201
202
# File 'lib/linkify-it-rb/index.rb', line 200

def text
  @text
end

#urlObject

Returns the value of attribute url.



200
201
202
# File 'lib/linkify-it-rb/index.rb', line 200

def url
  @url
end

Class Method Details

.createMatch(obj, shift) ⇒ Object




239
240
241
242
243
# File 'lib/linkify-it-rb/index.rb', line 239

def self.createMatch(obj, shift)
  match = Match.new(obj, shift)
  obj.__compiled__[match.schema][:normalize].call(match, obj)
  return match
end