Class: Mindee::Parsing::Standard::DateField

Inherits:
Field show all
Defined in:
lib/mindee/parsing/standard/date_field.rb

Overview

Represents a date.

Instance Attribute Summary collapse

Attributes inherited from Field

#reconstructed

Attributes inherited from AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from AbstractField

array_confidence, array_sum, float_to_string, #to_s

Constructor Details

#initialize(prediction, page_id) ⇒ DateField

Returns a new instance of DateField.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


27
28
29
30
31
32
33
34
# File 'lib/mindee/parsing/standard/date_field.rb', line 27

def initialize(prediction, page_id)
  super
  @is_computed = prediction['is_computed']
  return unless @value

  @date_object = Date.parse(@value)
  @raw = prediction['raw']
end

Instance Attribute Details

#date_objectDate? (readonly)

The date as a standard Ruby Date object.

Returns:

  • (Date, nil)


14
15
16
# File 'lib/mindee/parsing/standard/date_field.rb', line 14

def date_object
  @date_object
end

#is_computedBoolean? (readonly)

Whether the field was computed or retrieved directly from the document.

Returns:

  • (Boolean, nil)


23
24
25
# File 'lib/mindee/parsing/standard/date_field.rb', line 23

def is_computed
  @is_computed
end

#rawString? (readonly)

The textual representation of the date as found on the document.

Returns:

  • (String, nil)


20
21
22
# File 'lib/mindee/parsing/standard/date_field.rb', line 20

def raw
  @raw
end

#valueString? (readonly)

The ISO 8601 representation of the date, regardless of the raw contents.

Returns:

  • (String, nil)


17
18
19
# File 'lib/mindee/parsing/standard/date_field.rb', line 17

def value
  @value
end