Class: Archimate::DataModel::Font
- Inherits:
-
Object
- Object
- Archimate::DataModel::Font
- Includes:
- Comparison
- Defined in:
- lib/archimate/data_model/font.rb
Instance Attribute Summary collapse
- #font_data ⇒ String, NilClass readonly
- #name ⇒ String, NilClass readonly
- #size ⇒ Float, NilClass readonly
- #style ⇒ Int, NilClass readonly
Class Method Summary collapse
-
.archi_font_string(str) ⇒ Object
Archi font strings look like this: “1|Arial |14.0|0|WINDOWS|1|0 |0|0|0|0 |0 |0|0|1|0|0|0|0 |Arial” “1|Arial |8.0 |0|WINDOWS|1|0 |0|0|0|0 |0 |0|0|1|0|0|0|0 |Arial” “1|Segoe UI Semibold|12.0|2|WINDOWS|1|-16|0|0|0|600|-1|0|0|0|3|2|1|34|Segoe UI Semibold” “1|Times New Roman |12.0|3|WINDOWS|1|-16|0|0|0|700|-1|0|0|0|3|2|1|18|Times New Roman”.
Instance Method Summary collapse
-
#initialize(name: nil, size: nil, style: nil, font_data: nil) ⇒ Font
constructor
A new instance of Font.
-
#style_string ⇒ Object
Move to file format.
- #to_archi_font ⇒ Object
- #to_s ⇒ Object
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #inspect, #pretty_print, #to_h
Constructor Details
#initialize(name: nil, size: nil, style: nil, font_data: nil) ⇒ Font
Returns a new instance of Font.
39 40 41 42 43 44 |
# File 'lib/archimate/data_model/font.rb', line 39 def initialize(name: nil, size: nil, style: nil, font_data: nil) @name = name @size = size.nil? ? nil : size.to_f @style = style.nil? ? nil : style.to_i @font_data = font_data end |
Instance Attribute Details
#font_data ⇒ String, NilClass (readonly)
20 |
# File 'lib/archimate/data_model/font.rb', line 20 model_attr :font_data, default: nil |
#name ⇒ String, NilClass (readonly)
10 |
# File 'lib/archimate/data_model/font.rb', line 10 model_attr :name, default: nil |
#size ⇒ Float, NilClass (readonly)
13 |
# File 'lib/archimate/data_model/font.rb', line 13 model_attr :size, default: nil |
#style ⇒ Int, NilClass (readonly)
TODO:
make this an enum
17 |
# File 'lib/archimate/data_model/font.rb', line 17 model_attr :style, default: nil |
Class Method Details
.archi_font_string(str) ⇒ Object
TODO:
move this to the archi file reader
Archi font strings look like this:
"1|Arial |14.0|0|WINDOWS|1|0 |0|0|0|0 |0 |0|0|1|0|0|0|0 |Arial"
"1|Arial |8.0 |0|WINDOWS|1|0 |0|0|0|0 |0 |0|0|1|0|0|0|0 |Arial"
"1|Segoe UI Semibold|12.0|2|WINDOWS|1|-16|0|0|0|600|-1|0|0|0|3|2|1|34|Segoe UI Semibold"
"1|Times New Roman |12.0|3|WINDOWS|1|-16|0|0|0|700|-1|0|0|0|3|2|1|18|Times New Roman"
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/archimate/data_model/font.rb', line 28 def self.archi_font_string(str) return nil if str.nil? font_parts = str.split("|") DataModel::Font.new( name: font_parts[1], size: font_parts[2].to_f, style: font_parts[3].to_i, font_data: str ) end |
Instance Method Details
#style_string ⇒ Object
TODO:
this isn’t standard
Move to file format
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/archimate/data_model/font.rb', line 60 def style_string case style when 1 "italic" when 2 "bold" when 3 "bold|italic" end end |
#to_archi_font ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/archimate/data_model/font.rb', line 50 def to_archi_font font_data || [ 1, name, size, style, "WINDOWS", 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, name ].map(&:to_s).join("|") end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/archimate/data_model/font.rb', line 46 def to_s "Font(name: #{name}, size: #{size}, style: #{style})" end |