Class: PRRD::Graph::Textalign

Inherits:
Entity
  • Object
show all
Defined in:
lib/prrd/graph/textalign.rb

Overview

PRRD Textalign Line class

Instance Attribute Summary

Attributes inherited from Entity

#data, #keys

Instance Method Summary collapse

Methods inherited from Entity

#method_missing, #validate_presence

Constructor Details

#initialize(values = nil) ⇒ Textalign

Constructor



11
12
13
14
15
16
17
# File 'lib/prrd/graph/textalign.rb', line 11

def initialize(values = nil)
  @keys = [
    :orientation
  ]

  super values
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PRRD::Entity

Instance Method Details

#to_sObject

Transform to a TEXTALIGN formatted string



20
21
22
23
24
25
26
27
28
29
# File 'lib/prrd/graph/textalign.rb', line 20

def to_s
  fail 'Empty textalign object' if @data.empty?

  validate_presence :orientation
  unless ['left', 'right', 'justified', 'center'].include? @data[:orientation].to_s
    fail 'Orientation option muts be: left|right|justified|center'
  end

  "TEXTALIGN:\"%s\"" % @data[:orientation]
end