Sha256: 4a15b141ccdee47cd18fe88775c63e0c789ceeefbc17420bf76d6d0bbff1740f
Contents?: true
Size: 830 Bytes
Versions: 3
Compression:
Stored size: 830 Bytes
Contents
# frozen_string_literal: true module RubyJard ## # Pick layout smartly depending on current window height and width class LayoutPicker def initialize(width, height, layouts: RubyJard::Layouts, config: RubyJard.config) @width = width @height = height @layouts = layouts @config = config end def pick unless @config.layout.nil? return @layouts[@config.layout] || @layouts.fallback_layout end @layouts.each do |_name, template| matched = true matched &&= ( template.min_width.nil? || @width > template.min_width ) matched &&= ( template.min_height.nil? || @height > template.min_height ) return template if matched end @layouts.fallback_layout end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby_jard-0.3.1 | lib/ruby_jard/layout_picker.rb |
ruby_jard-0.3.0 | lib/ruby_jard/layout_picker.rb |
ruby_jard-0.2.3 | lib/ruby_jard/layout_picker.rb |