Class: OLE_QA::Framework::Line_Object

Inherits:
Data_Object show all
Defined in:
lib/common/line_object.rb

Overview

A Data Object in OLE that represents a single line in a given area. A line object can usually be added or deleted, and may or may not have its own line objects beneath it in the page-object hierarchy.

Instance Attribute Summary collapse

Attributes inherited from Common_Object

#elements, #functions, #ole

Instance Method Summary collapse

Methods inherited from Common_Object

#set_elements, #set_functions

Methods included from Helpers

#browser, #load_yml, #set_element, #set_function

Constructor Details

#initialize(ole_session, line_number = 1) ⇒ Line_Object

Returns a new instance of Line_Object.

Parameters:

  • ole_session (Object)

    The OLE_QA::Framework::Session session to pass to the Data Object.

  • line_number (Fixnum) (defaults to: 1)

    The number this line object will use for element definitions.



31
32
33
34
35
36
# File 'lib/common/line_object.rb', line 31

def initialize(ole_session, line_number = 1)
  @line_number = line_number
  super(ole_session)
  @sublines = Array.new
  set_sublines if defined?(self.set_sublines)
end

Instance Attribute Details

#line_numberObject

The line number that this object will have on the screen.

  • This is the 1-based line number used for replacement of human-readable identifiers.



24
25
26
# File 'lib/common/line_object.rb', line 24

def line_number
  @line_number
end

#sublinesObject (readonly)

An array containing the name (Symbol) of each subline element on the line object.



27
28
29
# File 'lib/common/line_object.rb', line 27

def sublines
  @sublines
end

Instance Method Details

#line_idObject

A reader method for the line_id function.

  • This is the 0-based line number used for replacement of programmatic identifiers such as element IDs.



40
41
42
# File 'lib/common/line_object.rb', line 40

def line_id
  @line_number - 1
end

#set_subline(name, klas, force = false) ⇒ Object Also known as: subline

Set a subline object definition on a page object.

  • A subline object created with this method becomes an accessor attribute associated with an instance variable on the page or data object on which it is created.

Parameters:

  • name (Symbol)

    The name the new subline object will have on the object. (This will be an instance variable, so it cannot contain spaces.)

  • klas (Class)

    The class to instantiate for the new subline object. (An error will be returned if the class given is not defined.)

  • force (Boolean) (defaults to: false)

    If set to true, this method can be used to override an existing subline object definition.

Raises:

  • StandardError if a parameter is of an incorrect type.

  • StandardError if an instance method already exists for a subline object with the same name. (Suppress with force = true.)



59
60
61
62
63
64
65
66
# File 'lib/common/line_object.rb', line 59

def set_subline(name, klas, force = false)
  raise StandardError, "Name must be a symbol.  Given:  #{name}  (#{name.class})" unless name.instance_of?(Symbol)
  raise StandardError, "Klas must be a class.  Given:  #{klas}  (#{klas.class})"  unless klas.instance_of?(Class)
  raise StandardError, "Subline object is already defined.  (Use the 'force = true' option to suppress this error.)" if @sublines.include?(name) && ! force
  instance_variable_set("@#{name}", klas.new(@ole, self, 1))
  make_reader(name) unless force
  @sublines << name unless force
end