Class: Uniword::Docx::Profile
- Inherits:
-
Object
- Object
- Uniword::Docx::Profile
- Defined in:
- lib/uniword/docx/profile.rb
Overview
Composition of three independent profile axes:
SystemProfile — "What Word version to target"
LocaleProfile — "What locale/language to use"
UserProfile — "Who is creating this document"
Used by Reconciler to populate DOCX parts with Word-expected content.
Constant Summary collapse
- CONFIG_DIR =
File.join(__dir__, "../../../config")
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.defaults ⇒ Object
Default profile (Office 2024, en-US).
-
.load(name, user: nil) ⇒ Profile
Load a named preset from config/profiles.yml.
Instance Method Summary collapse
- #app_version ⇒ Object
- #application_name ⇒ Object
- #bidi_lang ⇒ Object
-
#body_font ⇒ Object
Delegate common values to sub-profiles.
- #compat_mode ⇒ Object
- #decimal_symbol ⇒ Object
- #east_asia_lang ⇒ Object
- #heading_font ⇒ Object
-
#initialize(system:, locale:, user: UserProfile.defaults) ⇒ Profile
constructor
A new instance of Profile.
- #lang ⇒ Object
- #list_separator ⇒ Object
- #theme_font_lang ⇒ Object
- #user_company ⇒ Object
- #user_name ⇒ Object
Constructor Details
#initialize(system:, locale:, user: UserProfile.defaults) ⇒ Profile
Returns a new instance of Profile.
27 28 29 30 31 |
# File 'lib/uniword/docx/profile.rb', line 27 def initialize(system:, locale:, user: UserProfile.defaults) @system = system @locale = locale @user = user end |
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
25 26 27 |
# File 'lib/uniword/docx/profile.rb', line 25 def locale @locale end |
#system ⇒ Object (readonly)
Returns the value of attribute system.
25 26 27 |
# File 'lib/uniword/docx/profile.rb', line 25 def system @system end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
25 26 27 |
# File 'lib/uniword/docx/profile.rb', line 25 def user @user end |
Class Method Details
.defaults ⇒ Object
Default profile (Office 2024, en-US)
55 56 57 58 59 60 61 |
# File 'lib/uniword/docx/profile.rb', line 55 def self.defaults new( system: SystemProfile.defaults, locale: LocaleProfile.from_locale("en"), user: UserProfile.defaults, ) end |
.load(name, user: nil) ⇒ Profile
Load a named preset from config/profiles.yml
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/uniword/docx/profile.rb', line 38 def self.load(name, user: nil) presets = load_presets key = name.to_s unless presets.key?(key) raise ArgumentError, "Profile preset '#{key}' not found. " \ "Available: #{presets.keys.join(', ')}" end preset = presets[key] sys = SystemProfile.load(preset["system"]) loc = LocaleProfile.from_locale(preset["locale"]) new(system: sys, locale: loc, user: user || UserProfile.defaults) end |
Instance Method Details
#app_version ⇒ Object
104 105 106 |
# File 'lib/uniword/docx/profile.rb', line 104 def app_version system.app_version end |
#application_name ⇒ Object
100 101 102 |
# File 'lib/uniword/docx/profile.rb', line 100 def application_name system.application_name end |
#bidi_lang ⇒ Object
80 81 82 |
# File 'lib/uniword/docx/profile.rb', line 80 def bidi_lang locale.bidi_lang end |
#body_font ⇒ Object
Delegate common values to sub-profiles
64 65 66 |
# File 'lib/uniword/docx/profile.rb', line 64 def body_font system.font_scheme&.minor_font end |
#compat_mode ⇒ Object
108 109 110 |
# File 'lib/uniword/docx/profile.rb', line 108 def compat_mode system.compat_mode end |
#decimal_symbol ⇒ Object
84 85 86 |
# File 'lib/uniword/docx/profile.rb', line 84 def decimal_symbol locale.decimal_symbol end |
#east_asia_lang ⇒ Object
76 77 78 |
# File 'lib/uniword/docx/profile.rb', line 76 def east_asia_lang locale.east_asia_lang end |
#heading_font ⇒ Object
68 69 70 |
# File 'lib/uniword/docx/profile.rb', line 68 def heading_font system.font_scheme&.major_font end |
#lang ⇒ Object
72 73 74 |
# File 'lib/uniword/docx/profile.rb', line 72 def lang locale.lang end |
#list_separator ⇒ Object
88 89 90 |
# File 'lib/uniword/docx/profile.rb', line 88 def list_separator locale.list_separator end |
#theme_font_lang ⇒ Object
112 113 114 |
# File 'lib/uniword/docx/profile.rb', line 112 def theme_font_lang { val: locale.lang, east_asia: locale.east_asia_lang } end |
#user_company ⇒ Object
96 97 98 |
# File 'lib/uniword/docx/profile.rb', line 96 def user_company user.company end |
#user_name ⇒ Object
92 93 94 |
# File 'lib/uniword/docx/profile.rb', line 92 def user_name user.name end |