Class: Text2svg::Option

Inherits:
Struct
  • Object
show all
Defined in:
lib/text2svg/option.rb

Constant Summary collapse

DEFAULTS =
[
  nil,             # font
  :left,           # text_align
  Encoding::UTF_8, # encoding
  false,           # bold
  false,           # italic
  nil,             # attribute
  "0,0,3000,3000", # char_size
  1,
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute

Returns:

  • (Object)

    the current value of attribute



2
3
4
# File 'lib/text2svg/option.rb', line 2

def attribute
  @attribute
end

#boldObject

Returns the value of attribute bold

Returns:

  • (Object)

    the current value of bold



2
3
4
# File 'lib/text2svg/option.rb', line 2

def bold
  @bold
end

#char_sizeObject

Returns the value of attribute char_size

Returns:

  • (Object)

    the current value of char_size



2
3
4
# File 'lib/text2svg/option.rb', line 2

def char_size
  @char_size
end

#encodingObject

Returns the value of attribute encoding

Returns:

  • (Object)

    the current value of encoding



2
3
4
# File 'lib/text2svg/option.rb', line 2

def encoding
  @encoding
end

#fontObject

Returns the value of attribute font

Returns:

  • (Object)

    the current value of font



2
3
4
# File 'lib/text2svg/option.rb', line 2

def font
  @font
end

#italicObject

Returns the value of attribute italic

Returns:

  • (Object)

    the current value of italic



2
3
4
# File 'lib/text2svg/option.rb', line 2

def italic
  @italic
end

#scaleObject

Returns the value of attribute scale

Returns:

  • (Object)

    the current value of scale



2
3
4
# File 'lib/text2svg/option.rb', line 2

def scale
  @scale
end

#text_alignObject

Returns the value of attribute text_align

Returns:

  • (Object)

    the current value of text_align



2
3
4
# File 'lib/text2svg/option.rb', line 2

def text_align
  @text_align
end

Class Method Details

.defaultObject



32
33
34
# File 'lib/text2svg/option.rb', line 32

def default
  new(*DEFAULTS)
end

.from_hash(h) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/text2svg/option.rb', line 24

def from_hash(h)
  o = new(*DEFAULTS)
  h.to_h.each do |k, v|
    o[k.to_sym] = v
  end
  o
end