Class: Stylegen::Data
- Inherits:
-
Object
- Object
- Stylegen::Data
- Defined in:
- lib/stylegen/data.rb
Instance Method Summary collapse
- #access_level ⇒ Object
- #basename ⇒ Object
- #colors ⇒ Object
- #inflector ⇒ Object
-
#initialize(data) ⇒ Data
constructor
A new instance of Data.
- #output_path ⇒ Object
- #struct_name ⇒ Object
- #swiftui? ⇒ Boolean
- #system_name ⇒ Object
- #util_method_name ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(data) ⇒ Data
Returns a new instance of Data.
9 10 11 |
# File 'lib/stylegen/data.rb', line 9 def initialize(data) @data = data end |
Instance Method Details
#access_level ⇒ Object
41 42 43 |
# File 'lib/stylegen/data.rb', line 41 def access_level @data["access_level"] || "internal" end |
#basename ⇒ Object
37 38 39 |
# File 'lib/stylegen/data.rb', line 37 def basename File.basename(@data["output_path"]) end |
#colors ⇒ Object
49 50 51 52 53 |
# File 'lib/stylegen/data.rb', line 49 def colors @colors ||= @data["colors"].map do |key, value| [inflector.camelize_lower(key), generate_color(value)] end end |
#inflector ⇒ Object
13 14 15 |
# File 'lib/stylegen/data.rb', line 13 def inflector @inflector ||= Dry::Inflector.new end |
#output_path ⇒ Object
29 30 31 |
# File 'lib/stylegen/data.rb', line 29 def output_path @data["output_path"] end |
#struct_name ⇒ Object
45 46 47 |
# File 'lib/stylegen/data.rb', line 45 def struct_name "#{system_name}Color" end |
#swiftui? ⇒ Boolean
33 34 35 |
# File 'lib/stylegen/data.rb', line 33 def swiftui? @data["swiftui"] || false end |
#system_name ⇒ Object
21 22 23 |
# File 'lib/stylegen/data.rb', line 21 def system_name @data["system_name"] || "Theme" end |
#util_method_name ⇒ Object
25 26 27 |
# File 'lib/stylegen/data.rb', line 25 def util_method_name inflector.camelize_lower(inflector.underscore(system_name)) end |