Class: Jektify::Main
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jektify::Main
- Defined in:
- lib/jektify/main.rb
Instance Method Summary collapse
-
#initialize(tag_name, input, tokens) ⇒ Main
constructor
A new instance of Main.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, input, tokens) ⇒ Main
Returns a new instance of Main.
57 58 59 60 |
# File 'lib/jektify/main.rb', line 57 def initialize(tag_name, input, tokens) super @input = input end |
Instance Method Details
#render(context) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/jektify/main.rb', line 62 def render(context) engine = Engine.new render_obj = Render.new config = engine.yml_config('_config.yml')[APP_NAME] # Split do input e configurações do Spotify input_split = engine.split_params(@input) spotify_user = input_split[0].strip = input_split[1].strip spotify_id = input_split[2].strip = input_split[3].strip = == "light" ? "white" : engine.error_different_string( , "dark", "white", "[x] Error: Parameter incorrect in {% spotify [user]/[type]/[id]/[theme] %}." ) player_color = == "dark" ? "0" : "1" = "https://open.spotify.com/embed/#{}/#{spotify_id}?theme=#{player_color}" # Validações das configs %w[enable open].each do |key| engine.error_different_true_false(config[key], "[x] Error: The property 'spotify => #{key}' in '_config.yml' is missing or invalid.") unless config[key].nil? end if config["title"] engine.error_different_true_false(config["title"]["enable"], "[x] Error: The property 'spotify => title => enable' in '_config.yml' is missing or invalid.") unless config["title"].nil? end if config["description"] engine.error_different_true_false(config["description"]["enable"], "[x] Error: The property 'spotify => description => enable' in '_config.yml' is missing or invalid.") unless config["description"].nil? end if config["toggle"] engine.error_different_true_false(config["toggle"]["enable"], "[x] Error: The property 'spotify => toggle => enable' in '_config.yml' is missing or invalid.") unless config["toggle"].nil? end # Renderiza o player render_obj.rendering(APP_NAME, config, , , ) end |