Class: LexM::LemmaRedirect

Inherits:
Object
  • Object
show all
Defined in:
lib/lexm/lemma_redirect.rb

Overview

Represents a redirection to another lemma, with optional relation types

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, types = []) ⇒ LemmaRedirect

Initialize a new redirection

Parameters:

  • target (String)

    the target lemma to redirect to

  • types (Array<String>) (defaults to: [])

    relation types (e.g., [“pl”], [“sp”, “pp”])



19
20
21
22
# File 'lib/lexm/lemma_redirect.rb', line 19

def initialize(target, types = [])
    @target = target
    @types = types || []
end

Instance Attribute Details

#targetObject

Returns the value of attribute target.



14
15
16
# File 'lib/lexm/lemma_redirect.rb', line 14

def target
  @target
end

#typesObject

Returns the value of attribute types.



14
15
16
# File 'lib/lexm/lemma_redirect.rb', line 14

def types
  @types
end

Instance Method Details

#to_sString

Convert to string representation

Returns:

  • (String)

    the string representation of this redirection



26
27
28
29
30
31
32
33
34
# File 'lib/lexm/lemma_redirect.rb', line 26

def to_s
    if @types.empty?
        ">#{@target}"
    elsif @types.length == 1
        ">(#{@types.first})#{@target}"
    else
        ">(#{@types.join(',')})#{@target}"
    end
end