Class: Squib::Args::Paragraph Private

Inherits:
Object
  • Object
show all
Includes:
ArgLoader
Defined in:
lib/squib/args/paragraph.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ArgLoader

#[], #convert_units, #defaultify, #expand_and_set_and_defaultify, #expandable_singleton?, #load!, #prep_layout_args, #validate

Constructor Details

#initialize(deck_font) ⇒ Paragraph

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Paragraph.



35
36
37
# File 'lib/squib/args/paragraph.rb', line 35

def initialize(deck_font)
  @deck_font = deck_font
end

Class Method Details

.expanding_parametersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



27
28
29
# File 'lib/squib/args/paragraph.rb', line 27

def self.expanding_parameters
  parameters.keys # all of them
end

.parametersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/squib/args/paragraph.rb', line 12

def self.parameters
  { align:     :left,
    str:       'Hello, World!',
    font:      :use_set,
    font_size: nil,
    markup:    false,
    justify:   false,
    wrap:      true,
    ellipsize: :end,
    spacing:   nil,
    valign:    :top,
    hint:      :off
  }
end

.params_with_unitsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/squib/args/paragraph.rb', line 31

def self.params_with_units
  [] # none of them
end

Instance Method Details

#validate_align(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/squib/args/paragraph.rb', line 49

def validate_align(arg, _i)
  case arg.to_s.downcase.strip
  when 'left'
    Pango::Alignment::LEFT
  when 'right'
    Pango::Alignment::RIGHT
  when 'center'
    Pango::Alignment::CENTER
  else
    raise ArgumentError, 'align must be one of: center, left, right'
  end
end

#validate_ellipsize(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/squib/args/paragraph.rb', line 75

def validate_ellipsize(arg, _i)
  case arg.to_s.downcase.strip
  when 'none', 'false'
    Pango::EllipsizeMode::NONE
  when 'start'
    Pango::EllipsizeMode::START
  when 'middle'
    Pango::EllipsizeMode::MIDDLE
  when 'end', 'true'
    Pango::EllipsizeMode::END
  else
    raise ArgumentError, 'ellipsize must be one of: none, start, middle, end, true, or false'
  end
end

#validate_font(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
46
47
# File 'lib/squib/args/paragraph.rb', line 43

def validate_font(arg, _i)
  arg = @deck_font if arg == :use_set
  arg = DEFAULT_FONT if arg == :default
  arg
end

#validate_justify(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



90
91
92
93
94
95
96
97
# File 'lib/squib/args/paragraph.rb', line 90

def validate_justify(arg, _i)
  case arg
  when nil, true, false
    arg
  else
    raise ArgumentError, 'justify must be one of: nil, true, or false'
  end
end

#validate_spacing(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (ArgumentError)


99
100
101
102
103
# File 'lib/squib/args/paragraph.rb', line 99

def validate_spacing(arg, _i)
  return nil if arg.nil?
  raise ArgumentError, 'spacing must be a number or nil' unless arg.respond_to? :to_f
  arg.to_f * Pango::SCALE
end

#validate_str(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



39
40
41
# File 'lib/squib/args/paragraph.rb', line 39

def validate_str(arg, _i)
  arg.to_s
end

#validate_valign(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



105
106
107
108
109
110
111
# File 'lib/squib/args/paragraph.rb', line 105

def validate_valign(arg, _i)
  if %w(top middle bottom).include? arg.to_s.downcase
    arg.to_s.downcase
  else
    raise ArgumentError, 'valign must be one of: top, middle, bottom'
  end
end

#validate_wrap(arg, _i) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/squib/args/paragraph.rb', line 62

def validate_wrap(arg, _i)
  case arg.to_s.downcase.strip
  when 'word'
    Pango::WrapMode::WORD
  when 'char', 'false'
    Pango::WrapMode::CHAR
  when 'word_char', 'true'
    Pango::WrapMode::WORD_CHAR
  else
    raise ArgumentError, 'wrap must be one of: word, char, word_char, true, or false'
  end
end