Class: Dphil::Verse

Inherits:
Object
  • Object
show all
Defined in:
lib/dphil/verse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(verse, ms: nil, id: nil) ⇒ Verse

Returns a new instance of Verse.



8
9
10
11
12
13
14
# File 'lib/dphil/verse.rb', line 8

def initialize(verse, ms: nil, id: nil)
  @verse = verse.to_str.safe_copy
  @ms = ms.safe_copy
  @id = id.safe_copy
  @identify = VerseAnalysis.identify(@verse)
  deep_freeze
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/dphil/verse.rb', line 6

def id
  @id
end

#identifyObject (readonly)

Returns the value of attribute identify.



6
7
8
# File 'lib/dphil/verse.rb', line 6

def identify
  @identify
end

#msObject (readonly)

Returns the value of attribute ms.



6
7
8
# File 'lib/dphil/verse.rb', line 6

def ms
  @ms
end

#syllablesObject (readonly)

Returns the value of attribute syllables.



6
7
8
# File 'lib/dphil/verse.rb', line 6

def syllables
  @syllables
end

#verseObject (readonly)

Returns the value of attribute verse.



6
7
8
# File 'lib/dphil/verse.rb', line 6

def verse
  @verse
end

#weightsObject (readonly)

Returns the value of attribute weights.



6
7
8
# File 'lib/dphil/verse.rb', line 6

def weights
  @weights
end

Instance Method Details

#to_json(options) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/dphil/verse.rb', line 16

def to_json(options)
  { ms: ms,
    id: id,
    verse: verse,
    syllables: syllables,
    weights: weights,
    identify: identify }.to_json(options)
end