Class: Plushie::Widget::QrCode
- Inherits:
-
Object
- Object
- Plushie::Widget::QrCode
- Defined in:
- lib/plushie/widget/qr_code.rb
Overview
QR Code -- renders a QR code from a data string.
Props:
- data (string) -- the data to encode.
- cell_size (number) -- size of each QR module in pixels.
- cell_color (string) -- color of dark modules.
- background_color (string) -- color of light modules.
- error_correction (symbol) -- :low, :medium, :quartile, :high.
- alt (string) -- accessible label.
- description (string) -- extended accessible description.
- a11y (hash) -- accessibility overrides.
Constant Summary collapse
- PROPS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Supported property keys for this widget.
%i[data cell_size cell_color background_color error_correction alt description a11y].freeze
Instance Attribute Summary collapse
-
#a11y ⇒ Object
readonly
Returns the value of attribute a11y.
-
#alt ⇒ Object
readonly
Returns the value of attribute alt.
-
#background_color ⇒ Object
readonly
Returns the value of attribute background_color.
-
#cell_color ⇒ Object
readonly
Returns the value of attribute cell_color.
-
#cell_size ⇒ Object
readonly
Returns the value of attribute cell_size.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#error_correction ⇒ Object
readonly
Returns the value of attribute error_correction.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #build ⇒ Plushie::Node
-
#initialize(id, data = nil, **opts) ⇒ QrCode
constructor
A new instance of QrCode.
Constructor Details
#initialize(id, data = nil, **opts) ⇒ QrCode
Returns a new instance of QrCode.
34 35 36 37 38 39 |
# File 'lib/plushie/widget/qr_code.rb', line 34 def initialize(id, data = nil, **opts) @id = id.to_s @data = data PROPS.each { |k| instance_variable_set(:"@#{k}", opts[k]) if opts.key?(k) } @data = opts[:data] if opts.key?(:data) end |
Instance Attribute Details
#a11y ⇒ Object (readonly)
Returns the value of attribute a11y.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def a11y @a11y end |
#alt ⇒ Object (readonly)
Returns the value of attribute alt.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def alt @alt end |
#background_color ⇒ Object (readonly)
Returns the value of attribute background_color.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def background_color @background_color end |
#cell_color ⇒ Object (readonly)
Returns the value of attribute cell_color.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def cell_color @cell_color end |
#cell_size ⇒ Object (readonly)
Returns the value of attribute cell_size.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def cell_size @cell_size end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def data @data end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def description @description end |
#error_correction ⇒ Object (readonly)
Returns the value of attribute error_correction.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def error_correction @error_correction end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
1 2 3 |
# File 'lib/plushie/widget/qr_code.rb', line 1 def id @id end |