Class: Stylegen::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/stylegen/data.rb

Instance Method Summary collapse

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_levelObject



41
42
43
# File 'lib/stylegen/data.rb', line 41

def access_level
  @data["access_level"] || "internal"
end

#basenameObject



37
38
39
# File 'lib/stylegen/data.rb', line 37

def basename
  File.basename(@data["output_path"])
end

#colorsObject



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

#inflectorObject



13
14
15
# File 'lib/stylegen/data.rb', line 13

def inflector
  @inflector ||= Dry::Inflector.new
end

#output_pathObject



29
30
31
# File 'lib/stylegen/data.rb', line 29

def output_path
  @data["output_path"]
end

#struct_nameObject



45
46
47
# File 'lib/stylegen/data.rb', line 45

def struct_name
  "#{system_name}Color"
end

#swiftui?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/stylegen/data.rb', line 33

def swiftui?
  @data["swiftui"] || false
end

#system_nameObject



21
22
23
# File 'lib/stylegen/data.rb', line 21

def system_name
  @data["system_name"] || "Theme"
end

#util_method_nameObject



25
26
27
# File 'lib/stylegen/data.rb', line 25

def util_method_name
  inflector.camelize_lower(inflector.underscore(system_name))
end

#versionObject



17
18
19
# File 'lib/stylegen/data.rb', line 17

def version
  Stylegen::VERSION
end