Class: DynamicPDFApi::LineStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_client/LineStyle.rb

Overview

Represents a style of line.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, dash_phase = 0) ⇒ LineStyle

Initializes a new instance of the LineStyle class.

Parameters:

  • line (Array)

    The array specifying the line style.

  • dash_phase (float) (defaults to: 0)

    The phase of the line style.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_client/LineStyle.rb', line 12

def initialize(line, dash_phase = 0)
  if line.is_a?(Array)
    str_line_style = '['
    (0..(line.length - 1)).each do |i|
      val = line[i]
      str_line_style = if i == (line.length - 1)
                         str_line_style + format('%.2f', val)
                       else
                         "#{str_line_style}#{format('%.2f', val)},"
                       end
    end
    str_line_style += ']'
    str_line_style += format('%.2f', dash_phase) if dash_phase != 0
    @_line_style_string = str_line_style
  else
    @_line_style_string = line
  end
end

Instance Attribute Details

#_line_style_stringObject

Returns the value of attribute _line_style_string.



31
32
33
# File 'lib/ruby_client/LineStyle.rb', line 31

def _line_style_string
  @_line_style_string
end

Class Method Details

.dashObject

Gets a dashed line.



57
58
59
# File 'lib/ruby_client/LineStyle.rb', line 57

def self.dash
  LineStyle.new('dash')
end

.dash_largeObject

Gets a line with large dashes.



64
65
66
# File 'lib/ruby_client/LineStyle.rb', line 64

def self.dash_large
  LineStyle.new('dashLarge')
end

.dash_smallObject

Gets a line with small dashes.



50
51
52
# File 'lib/ruby_client/LineStyle.rb', line 50

def self.dash_small
  LineStyle.new('dashSmall')
end

.dotsObject

Gets a dotted line.



43
44
45
# File 'lib/ruby_client/LineStyle.rb', line 43

def self.dots
  LineStyle.new('dots')
end

.noneObject

Gets a invisible line.



71
72
73
# File 'lib/ruby_client/LineStyle.rb', line 71

def self.none
  LineStyle.new('none')
end

.solidObject

Gets a solid line.



36
37
38
# File 'lib/ruby_client/LineStyle.rb', line 36

def self.solid
  LineStyle.new('solid')
end

Instance Method Details

#to_json(_options = {}) ⇒ Object



75
76
77
# File 'lib/ruby_client/LineStyle.rb', line 75

def to_json(_options = {})
  JSON.pretty_generate({})
end