Class: Unmagic::Browser::Console::Tagged

Inherits:
String
  • Object
show all
Defined in:
lib/unmagic/browser/console/values.rb

Overview

A String that also knows how it wants to be shown.

Sniffing a value to guess whether it's HTML, Markdown or PNG bytes would be guesswork the console doesn't need to do: the helper that produced it knows exactly what it asked for. These carry that answer through to the renderer while staying plain Strings for everything else, so html.include?("...") and puts markdown work the way you'd expect.

Direct Known Subclasses

Code, Document, Image

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, name:) ⇒ Tagged

Returns a new instance of Tagged.

Parameters:

  • value (String)

    the bytes themselves

  • name (String)

    what to call it in the console, and on disk



16
17
18
19
# File 'lib/unmagic/browser/console/values.rb', line 16

def initialize(value, name:)
  super(value.to_s)
  @name = name
end

Instance Attribute Details

#nameString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/unmagic/browser/console/values.rb', line 22

def name
  @name
end