Class: Relaton::Plateau::Stagename

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/plateau/stagename.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, abbreviation: nil) ⇒ Stagename

Initialize the Stagename object

Parameters:

  • content (String)

    name of the stage

  • abbreviation (String) (defaults to: nil)

    abbreviation of the stage



16
17
18
19
# File 'lib/relaton/plateau/stagename.rb', line 16

def initialize(content:, abbreviation: nil)
  @content = content
  @abbreviation = abbreviation
end

Instance Attribute Details

#abbreviationString? (readonly)

Returns:

  • (String, nil)


8
9
10
# File 'lib/relaton/plateau/stagename.rb', line 8

def abbreviation
  @abbreviation
end

#contentString (readonly)

Returns:

  • (String)


5
6
7
# File 'lib/relaton/plateau/stagename.rb', line 5

def content
  @content
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ Object



34
35
36
37
38
39
# File 'lib/relaton/plateau/stagename.rb', line 34

def to_asciibib(prefix = "")
  pref = prefix.empty? ? "stagename" : "#{prefix}.stagename"
  output = "#{pref}.content:: #{content}\n"
  output += "#{pref}.abbreviation:: #{abbreviation}\n" if abbreviation
  output
end

#to_hashObject



28
29
30
31
32
# File 'lib/relaton/plateau/stagename.rb', line 28

def to_hash
  hash = { content: content }
  hash[:abbreviation] = abbreviation if abbreviation
  hash
end

#to_xml(builder) ⇒ Object



21
22
23
24
25
26
# File 'lib/relaton/plateau/stagename.rb', line 21

def to_xml(builder)
  builder.stagename do |b|
    b.parent[:abbreviation] = abbreviation if abbreviation
    b.text content
  end
end