Newbie question: Can't find info on 'define'

Hi,

I’m looking over some code (Asciidoctor), and in one file there are
several ‘define’ statements enclosed in a module. An example of this is
the following in a .rb file:

define :block_terminates_paragraph, true

define :strict_verbatim_paragraphs, true

I’ve seen ‘define_method’ documented but not the keyword ‘define’. It
seems like it might be defining symbolic constants, but I’m not sure.

Could someone clarify this?

Thanks.

Les

It’s not a keyword, it’s a (class) method defined by asciidoctor.

See here for the source:

https://github.com/asciidoctor/asciidoctor/blob/502307c670eb952eac729b109d3288de24fc9cfb/lib/asciidoctor.rb

Defines a new compliance key and

assigns an initial value.

def self.define key, value
instance_variable_set %(@#{key}),
value
class << self
self
end.send :attr_accessor, key
@keys << key
nil
end

Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs