Eno::Section » #element

element(name) → element or nil
element(name, options) → element or nil

Retrieve a single element of any allowed type from the section by its name. Optionally specify whether it's optional or mandatory for the element to be present in the eno document (by default it's optional).

enotitle: Artfest 2018
tags:
- art
- code

# content
> ...
rubydocument = Eno.parse(input)

document.element('title')  #=> #<Eno::Field name="title" value="Artfest 2018">
document.element('tags')  #=> #<Eno::List name="tags" items=2>
document.element('content')  #=> #<Eno::Section name="content" items=14>

document.element('fantasy')  #=> nil
document.element('fantasy', enforce_element: true)  #=> raises an error
document.element('fantasy', required: true)  #=> raises an error

Parameters

name

The name of the element to fetch from the section as a string.

options

enforce_element

Whether the element must be present in the document (true or false, defaults to false)

required

Alias for enforce_element (this exists on many methods and depending on context refers to either element or value)

Return value

An element (e.g. Eno::List, Eno::Field, etc.) or nil.