Class: YuiRestClient::Widgets::Datefield

Inherits:
Base
  • Object
show all
Defined in:
lib/yui_rest_client/widgets/datefield.rb

Overview

Class representing a date field in the UI, namely YDateField.

Instance Method Summary collapse

Methods inherited from Base

#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property

Methods included from YuiRestClient::Waitable

#wait_until, #wait_while

Constructor Details

This class inherits a constructor from YuiRestClient::Widgets::Base

Instance Method Details

#set(date) ⇒ Datefield

Sends action to set the value of date field. Accepts Date, Time or DateTime object and sets value in ISO 8601 format YYYY-MM-DD.

Examples:

Set date in date field with id ‘test’ to current date

app.datefield(id: 'date').set(Time.now)

Set date in date field with id ‘test’ to 2002-12-29

app.datefield(id: 'date').set(DateTime.new(2002,12,29))

Set date in date field with id ‘test’ to 2021-02-03

app.datefield(id: 'date').set(Date.new(2001,2,3))

Parameters:

  • date (Date)

    date to be set in date field

Returns:

  • (Datefield)

    in case action is successful

Raises:

  • YuiRestClientError if parameter is not Date, DateTime or Time



18
19
20
21
22
23
24
25
# File 'lib/yui_rest_client/widgets/datefield.rb', line 18

def set(date)
  unless  [Date, DateTime, Time].any? { |c| date.is_a? c }
    raise Error::YuiRestClientError, 'Parameter is not Date, Time or DateTime'
  end

  action(action: Actions::ENTER_TEXT, value: date.strftime('%F'))
  self
end

#valueString

Returns text that is currently set for datefield. Gets value from ‘value’ parameter in JSON representation of YDateField.

Examples:

Get value from datefield with id “date”

{
    "class" : "YDateField",
    "debug_label" : "Date:",
    "hstretch" : true,
    "id" : "date",
    "label" : "&Date:",
    "notify" : true,
    "value" : "1989-11-09"
}
app.datefield(id: 'date').value # '1989-11-09'

Returns:

  • (String)

    value



42
43
44
# File 'lib/yui_rest_client/widgets/datefield.rb', line 42

def value
  property(:value)
end